Trying to filter out some services with a relabel_config
. On the target I have a label app.kubernetes.io/name
with a value of kube-state-metrics
.
When I set up my relabel-configs
I realized the .
and the /
are not valid according to the Prometheus documentation. I get an error complaining of these invalid characters. Outside of adding a new label on to this service, is this achievable the way it sets? Most Helm charts use this label convention so it would be a lot of work to add additional labels for everything, hoping to avoid it.
relabel_configs:
- source_labels: [app.kubernetes.io/name]
action: keep
regex: kube-state-metrics
CodePudding user response:
Prometheus changes dots .
and slashes /
to underscores _
during service discovery, so you need to replace them as well: app_kubernetes_io_name
. But this isn't the end, you may also need to add __meta_kubernetes_pod_label_
prefix to it:
- job_name: 'pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
action: keep
regex: kube-state-metrics