How to add new label for particular vm's

35 views
Skip to first unread message

Владимир organ2

unread,
Jul 2, 2020, 6:00:50 AM7/2/20
to Prometheus Users
Hello.
I use vmware exporter. 
For convenient notification management I want to add separate labels new label "group_host" with name "critical_hosts" for all metrics which contain label vm_name=host1 or host2.

Here's some metrics form prometheus:
vmware_vm_cpu_demand_average{cluster_name="Cluster",dc_name="Datacenter",host_name="esxi",instance="10.10.10.10:9272",job="vmware hosts",tags="n/a",vm_name="host1"}
vmware_vm_cpu_demand_average{cluster_name="Cluster",dc_name="Datacenter",host_name="esxi",instance="10.10.10.10.:9272",job="vmware hosts",tags="n/a",vm_name="host2"}
vmware_vm_cpu_demand_average{cluster_name="Cluster",dc_name="Datacenter",host_name="esxi",instance="10.10.10.10:9272",job="vmware hosts",tags="n/a",vm_name="host3"}
vmware_vm_cpu_demand_average{cluster_name="Cluster",dc_name="Datacenter",host_name="esxi",instance="10.10.10.10:9272",job="vmware hosts",tags="n/a",vm_name="host4"}


I wrote this relaballing but it doesn't work:

    relabel_configs:
      - source_labels: [vm_name]
        regex: host1|host2
        replacement: critical_hosts
        target_label: group_host
        action: replace

Matthias Rampke

unread,
Jul 2, 2020, 3:49:51 PM7/2/20
to Владимир organ2, Prometheus Users
Relabel configs apply in the service discovery stage, once for each target – it looks like you have one instance, so you probably need `metric_relabel_configs`. Those are applied to the metric after scraping.

/MR

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/9284dfa1-4779-4a64-b5b8-683c9ab2d163o%40googlegroups.com.

Владимир organ2

unread,
Jul 3, 2020, 5:58:50 AM7/3/20
to Prometheus Users
Thank you! It works!

четверг, 2 июля 2020 г., 22:49:51 UTC+3 пользователь Matthias Rampke написал:
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages