Skip to main content

Overview

The Kubernetes Dashboard Metrics API provides access to resource metrics through integration with the metrics-scraper sidecar. Metrics include CPU usage, memory usage, and custom application metrics.

Metrics Architecture

The metrics system consists of:
  • Metrics-Scraper Sidecar: Collects metrics from Kubernetes metrics server
  • Integration Manager: Manages metrics provider connections
  • Metric Client: Downloads and aggregates metric data
  • REST API: Exposes metrics through Dashboard endpoints

Configuration

Metrics Provider

string
default:"sidecar"
Metrics provider to useOptions:
  • sidecar: Use the metrics-scraper sidecar (default)
  • none: Disable metrics collection
string
Metrics-scraper sidecar host URLExample: http://dashboard-metrics-scraper:8000
duration
default:"30s"
Health check interval for metrics client

In-Cluster Configuration

When running in-cluster, the sidecar is accessed via Kubernetes service:

Metrics Integration

Sidecar Integration

The API integrates with the metrics-scraper sidecar:

Health Check

Check metrics integration health:
endpoint
Health check for sidecar metrics integration
boolean
Whether the integration is healthy
string
Health status message

Available Metrics

CPU Metrics

metric
CPU usage in nanocores
metric
CPU request in nanocores
metric
CPU limit in nanocores

Memory Metrics

metric
Memory usage in bytes
metric
Memory request in bytes
metric
Memory limit in bytes

Query Parameters

Metric Names

string
Comma-separated list of metrics to retrieveExample: metricNames=cpu/usage,memory/usage

Aggregations

string
default:"sum"
Aggregation method for metricsOptions:
  • sum: Sum all values
  • avg: Average of values
  • min: Minimum value
  • max: Maximum value

Resource-Specific Metrics

Many resource endpoints support the metricNames query parameter to include metrics in the response.

Pod Metrics

endpoint
Get pods with CPU and memory metrics

Example Request

Example Response

Deployment Metrics

endpoint
Get deployments with aggregated metrics from all pods

Node Metrics

endpoint
Get nodes with system metrics

Metric Data Structures

Metric Object

string
Name of the metric (e.g., cpu/usage)
array
Array of data points for chartingStructure:
array
Array of metric points with timestampsStructure:
object
Resource labels for the metricStructure:

Sidecar REST API

The metrics-scraper sidecar exposes its own REST API:

Base Path

Pod Metrics

endpoint
Get metrics for a specific pod

Batch Pod Metrics

endpoint
Get metrics for multiple pods in one request

Node Metrics

endpoint
Get metrics for a specific node

Metric Client Interface

The Dashboard uses a metric client interface to download and aggregate metrics:

Download Metrics

Aggregate Metrics

Resource Selectors

Metric downloads use resource selectors to specify target resources:

Example

Aggregation Modes

Sum Aggregation

Adds all metric values:

Average Aggregation

Calculates the mean:

Min/Max Aggregation

Finds minimum or maximum values:

Batch Metric Downloads

The system optimizes metric downloads by:
  1. Compressing selectors: Combining similar requests
  2. Batch downloads: Downloading multiple resources in one request
  3. Parallel processing: Using goroutines for concurrent downloads

All-in-One Downloads

Supported resource types for batch downloads:
  • Pods
  • Nodes
  • PersistentVolumeClaims

Metric Promises

Metrics are returned as promises for asynchronous processing:

Usage Example

Prometheus Metrics

The Dashboard exposes its own Prometheus metrics at:
endpoint
Prometheus metrics endpoint

Available Metrics

counter
Total API requests by verb, resource, client, content type, and codeLabels: verb, resource, client, contentType, code
histogram
Request latency distribution in microsecondsLabels: verb, resourceBuckets: 125ms, 250ms, 500ms, 1s, 2s, 4s, 8s
summary
Request latency summary with 1-hour sliding windowLabels: verb, resource

Error Handling

Metric Unavailable

When metrics are not available:

Sidecar Connection Error

If the sidecar is unreachable:

Example: Complete Metrics Query

Request

Response

Best Practices

Performance

  1. Request only needed metrics: Don’t request all metrics if you only need CPU
  2. Use aggregations: Let the API aggregate instead of doing it client-side
  3. Batch requests: Request metrics for multiple resources in list endpoints
  4. Cache results: Implement client-side caching for dashboards

Metric Selection

Troubleshooting

  1. Check sidecar health: Verify metrics-scraper is running
  2. Verify metrics-server: Ensure metrics-server is deployed in cluster
  3. Check RBAC: Ensure service account has metrics read permissions
  4. Review logs: Check Dashboard and sidecar logs for errors