I've setup rules to alert via email in Prometheus AlertManager and I've noticed I can use $hostname with the node_exporter job but not the windows_exporter job.
In the rule, I've configured the following:
annotations:
summary: "{{ $labels.instance }} instance is down"
If I replace $labels.instance with $labels.hostname, it only works with the node_exporter job but not the windows_exporter job.
Looking at the windows_exporter github page ...
Github Windows Exporter
... the "cs" collector has a hostname label:
How can I use this hostname label in the rule as I'm trying to avoid the port number that comes with $labels.instance.
Thanks.
I've setup rules to alert via email in Prometheus AlertManager and I've noticed I can use $hostname with the node_exporter job but not the windows_exporter job.
In the rule, I've configured the following:
annotations:
summary: "{{ $labels.instance }} instance is down"
If I replace $labels.instance with $labels.hostname, it only works with the node_exporter job but not the windows_exporter job.
Looking at the windows_exporter github page ...
Github Windows Exporter
... the "cs" collector has a hostname label:
How can I use this hostname label in the rule as I'm trying to avoid the port number that comes with $labels.instance.
Thanks.
Funny story ... once i added "relabel_configs" to the Windows Exporter job, it worked great for my alerts.
Not so great for the Grafana Windows Exporter Dashboard (ID:21697). Some of the metrics were showing 2 values:
Anyway, that's for another thread. Gonna go get a stiff double shot to drown my sorrows.
I had to add the relabel_configs under both the node_exporter and windows_exporter jobs as follows:
relabel_configs:
- source_labels: [__address__]
target_label: instance
- source_labels: [instance]
target_label: hostname
regex: '([^:]+).*'
replacement: '${1}'
I had missed the above under the Windows_exporter job previously.
Cheers.
hostname
label is expected even for node_exporter. See example here – markalex Commented Feb 4 at 8:17static_configs
or some form of service discovery? Also, any chance you have hostname directly specified for each target in config as an additional label? – markalex Commented Feb 4 at 8:19