Hello,
I have several servers with node_exporter running. And in they show up in Prometheus as below,
In my Grafana, Prometheus is already added as a datasource.
Also telegram is added as contact point and tested that its working.
How can I setup a single alert rule in grafana that can send me message to telegram with content
“node_exporter on {{ instance }} is down“ when node_exporter on any of instance is down?
Thanks.
Thank you for responding. I tested this. And alert came as below,
Status: firing
Rule: Node exporter down
Value: 0
I would like get the instance name, somewhere in that message.
Here is a screen shot of the alert I created as you explained. If you could please review and let me know anything I am doing wrong.
@simtcrom Please copy the same message to description field as summary
@prashanthan1987
Changed it and tested and still alert message came as same,
Status: firing
Rule: Node exporter down
Value: 0
I also found below logs upon running,
sudo journalctl -u grafana-server.service -e --no-pager
Sep 18 10:32:08 pi5server grafana[6046]: logger=ngalert.state.manager rule_uid=feycqvmxxotfkf org_id=1 t=2025-09-18T10:32:08.340935755+05:30 level=error msg="Error in expanding template" error="failed to expand template '{{- $labels := .Labels -}}{{- $values := .Values -}}{{- $value := .Value -}}Node {{ $instance }} is down': error parsing template __alert_Node exporter down: template: __alert_Node exporter down:1: undefined variable \"$instance\""
Thanks for sharing screenshots. I am look into it.
2 Likes
I was able to finally make it work.
my alert settings as below,
query: ```up{job="node"}
```
condition: ``WHEN LAST OF QUERY IS BELOW 1
```
Then under ``Configure notification message
```
Added two custom annotation as below,
name: prefix
content: {{ $labels.instance }} is down
name: message
content: {{ $labels.instance }} is down
Then created a notification template as below,
{{ define "telegram_node_exporter_down" }}
{{ if gt (len .Alerts.Firing) 0 }}
{{ with (index .Alerts.Firing 0) }}
Status: {{ "\u200B🚨" }} FIRING
Rule: {{ .Labels.alertname }}
Time: {{ .StartsAt }}
Prefix: {{ or .Labels.prefix .Labels.instance }}
Message: {{ or .Labels.message (print .Labels.instance " is down") }}
{{ end }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
{{ with (index .Alerts.Resolved 0) }}
Status: ✅ RESOLVED
Rule: {{ .Labels.alertname }}
Time: {{ .EndsAt }}
Prefix: {{ or .Labels.prefix .Labels.instance }}
Message: {{ or .Labels.message (print .Labels.instance " is back UP") }}
{{ end }}
{{ end }}
{{ end }}
Under telegram contact point under optional telegram settings, edit message and select above notification template.
This would now trigger the alert as below,