Hi there, I've got a job that does service discovery for "pods" in kubernetes and generates metrics like the following:
http_server_request_duration_seconds_bucket{path="/path1",pod="podName"}
http_server_request_duration_seconds_bucket{path="/path2",pod="podName"}
http_server_request_duration_seconds_bucket{path="/path3",pod="podName"}
http_server_request_duration_seconds_bucket{path="foo",pod="podName"}
http_server_request_duration_seconds_bucket{path="bar23324",pod="podName"}
http_server_request_duration_seconds_bucket{path="baz",pod="podName"}
http_server_request_duration_seconds_bucket{path="something completely random here",pod="podName"}
http_server_requests_total{path="/path5",pod="someOtherPod"}
http_server_requests_total{path="/path6",pod="someOtherPod"}
inf_metric{name="foo",pod="someOtherPod"}
some_other_metric_count{name="bar",pod="someOtherPod2"}
I want to DROP any metrics that match a certain pod and the metric name "http_server_request_duration_seconds_bucket " and DON'T contain the following values for the "path" label: "path1, path2, path3". These are the only values I want to "keep" so to speak.
I'm not sure how to accomplish this using a "metric_relabel_config", because if I match on "^http_server_request_duration_seconds_bucket;podName;.*path1|.*path2|.*path3$' and tell it to "keep" the values, it throws away ALL the other metrics for ALL other pods and keeps only a very small set. This is obviously not what I want. I want to keep the metrics for all of my pods, but I want to drop a small set of metrics from a certain pod that DON'T match the regex I've specified and I'm not sure how to do this.
I'm trying something like this as an example, which doesn't work - it deletes ALL other metrics for all other pods.
- job_name: 'k8s-pods'
scrape_interval: 30s
metric_relabel_configs:
- source_labels: [ __name__, pod, path ]
regex: ^http_server_request_duration_seconds_bucket;podName;.*path1|.*path2$
action: keep
Ideally I'd like to use a "drop" apply a "!" or a "NOT" type operator to the regex if that's possible?