show hostname rather than internal ip in alert message

52 views
Skip to first unread message

nina guo

unread,
May 10, 2021, 11:27:56 PM5/10/21
to Prometheus Users
Hi,

Many I ask how to show hostname rather than internal ip in alert message.
With the following settings, $labels.hostname still displays the internal ip.

alert rules definition:
----------------------------
      - alert: HighCpuLoad
        expr: 100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "High CPU load (instance {{ $labels.hostname }})"
---------------------------------

relabel config
----------------------------------
relabel_configs:
         - source_labels: [__meta_openstack_instance_name]
           target_label: hostname
-------------------------------------
Reply all
Reply to author
Forward
0 new messages