Collect NPU metrics with Prometheus¶
Connect the Operator's Metrics Exporter to Prometheus and query NPU temperatures by node.
Use the Metrics Exporter configuration. If the Operator is not installed, follow Installing the NPU Operator.
Start with a cluster that has Prometheus Operator installed. If it is not installed, follow the kube-prometheus-stack installation guide.
1. Connect the scrape target¶
Check the labels Prometheus uses to select ServiceMonitors and the port name of the Exporter Service.
$ kubectl get prometheus -n monitoring kube-prometheus-stack-prometheus \
-o jsonpath='{.spec.serviceMonitorSelector.matchLabels}{"\n"}'
{"release":"kube-prometheus-stack"}
$ kubectl get service -n rbln-system rbln-metrics-exporter-service \
-o jsonpath='{.spec.ports[0].name}{"\t"}{.spec.ports[0].port}{"\n"}'
http 9090
The ServiceMonitor's metadata.labels must match the Prometheus selector. Set spec.selector to match the Exporter Service labels. Set endpoints.port to the Service port name http rather than the port number.
2. Query metrics¶
Start port forwarding to Prometheus in one terminal.
Keep port forwarding running and query the metrics from another terminal. If the results are empty, wait for Prometheus to discover the new scrape target and try again.
$ curl -sS --get http://127.0.0.1:19090/api/v1/query \
--data-urlencode 'query=up{service="rbln-metrics-exporter-service"}' | \
jq -r '.data.result[] | [.metric.pod, .value[1]] | @tsv'
rbln-metrics-exporter-k6rs8 1
rbln-metrics-exporter-frs5x 1
The check passes when each Exporter reports up=1 and NPU temperatures are collected from each node. Device counts and temperatures vary by environment.
Metrics are missing
Check the ServiceMonitor labels, namespaces and port name. Also check the Prometheus Targets page for errors.
Clean up¶
Press Ctrl+C in the terminal running port forwarding, then delete the ServiceMonitor.