kubernetes-sigs / prometheus-adapter

An implementation of the custom.metrics.k8s.io API using Prometheus
Apache License 2.0
1.92k stars 554 forks source link

Edit the LabelMatchers in resourceRules #570

Closed raphaelfan closed 1 year ago

raphaelfan commented 1 year ago

Where can I edit the LabelMatchers used in the following rules?

resource:
    cpu:
      containerLabel: container
      containerQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>,
        container!=""}[3m])) by (<<.GroupBy>>)
      nodeQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>, id='/'}[3m]))
        by (<<.GroupBy>>)
      resources:
        overrides:
          instance:
            resource: node
          namespace:
            resource: namespace
          pod:
            resource: pod
    memory:
      containerLabel: container
      containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>, container!=""})
        by (<<.GroupBy>>)
      nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'})
        by (<<.GroupBy>>)
      resources:
        overrides:
          instance:
            resource: node
          namespace:
            resource: namespace
          pod:
            resource: pod
    window: 3m
logicalhan commented 1 year ago

/triage accepted /kind support /assign @dgrisonnet

dgrisonnet commented 1 year ago

LabelMatchers are being generated based on the resource overrides that you provide and the resource that the query to prometheus-adapter targets. As per your configuration, the instance label will be set to the node name and so on.

I would recommend reading https://github.com/kubernetes-sigs/prometheus-adapter/blob/master/docs/config-walkthrough.md in order to better understand prometheus-adapter configuration.