Skip to content

Commit aeba5f5

Browse files
committed
Scrape_configs: retain cAdvisor metrics for system processes
Currently, CPU metrics for Kubelet, Containerd, etc. are dropped by a relabel rule since they don't have a container image. On most systems they run in their own cgroup called `system.slice`, so we can add another rule which uses that fact to give the `image` label a value and then they won't be dropped.
1 parent 254dfb6 commit aeba5f5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

prometheus/scrape_configs.libsonnet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@
255255
],
256256

257257
metric_relabel_configs: [
258+
// Let system processes like kubelet survive the next rule by giving them a fake image.
259+
{
260+
source_labels: ['__name__', 'id'],
261+
regex: 'container_([a-z_]+);/system.slice/(.+)',
262+
target_label: 'image',
263+
replacement: '$2',
264+
},
265+
258266
// Drop container_* metrics with no image.
259267
{
260268
source_labels: ['__name__', 'image'],

0 commit comments

Comments
 (0)