경로 /usr/share/grafana/public/emails
ng_alert_notification.html 백업 후 작업
vi ng_alert_notification.html
{{ if .Alerts.Firing }}
<div style="background-color: #ededed; padding: 20px; border-radius: 10px; margin-bottom: 15px;">
<h2 style="font-size: 18pt; color: #b30000;"> Problem</h2>
{{ range .Alerts.Firing }}
<p style="font-size: 13pt;">{{ .Labels.alertname }}</p>
<p style="font-size: 12pt;"><strong>Host:</strong> {{ .Annotations.summary }}</p>
<p style="font-size: 12pt;"><strong>Time:</strong> {{ .StartsAt.Format "2006-01-02 15:04" }}</p>
<p style="font-size: 11pt;">실제 SAP HANA memory 사용량 입니다</p>
<a href="{{ .GeneratorURL }}"
style="display: inline-block; margin: 10px; padding: 10px 15px; background-color: #424242; color: white; text-decoration: none; border-radius: 5px;"
target="_blank">View Alert</a>
<a href="{{ .DashboardURL }}"
style="display: inline-block; margin: 10px; padding: 10px 15px; background-color: #424242; color: white; text-decoration: none; border-radius: 5px;"
target="_blank">View Dashboard</a>
{{ end }}
</div>
{{ else if .Alerts.Resolved }}
<div style="background-color: #ededed; padding: 20px; border-radius: 10px; margin-bottom: 15px;">
<h2 style="font-size: 18pt; color: #2e7d32;"> Resolved</h2>
{{ range .Alerts.Resolved }}
<p style="font-size: 13pt;">{{ .Labels.alertname }}</p>
<p style="font-size: 12pt;"><strong>Host:</strong> {{ .Annotations.summary }}</p>
<p style="font-size: 12pt;"><strong>Time:</strong> {{ .StartsAt.Format "2006-01-02 15:04" }}</p>
<p style="font-size: 11pt;">실제 SAP HANA memory 사용량 입니다</p>
<a href="{{ .GeneratorURL }}"
style="display: inline-block; margin: 10px; padding: 10px 15px; background-color: #424242; color: white; text-decoration: none; border-radius: 5px;"
target="_blank">View Alert</a>
<a href="{{ .DashboardURL }}"
style="display: inline-block; margin: 10px; padding: 10px 15px; background-color: #424242; color: white; text-decoration: none; border-radius: 5px;"
target="_blank">View Dashboard</a>
{{ end }}
</div>
{{ end }}
위에 수정 후 무조건 재 시작해야 적용됨
systemctl restart grafana-server.service
Message Subject 무조건 비워둬야 ng_alert~.html 적용됨
grafana slack template
{{ define "alert_notification_title1" }}
[{{ .Status }}] {{ range .Alerts }}{{ index .Labels "alertname" }}{{ end }}
{{ end }}
{{ define "alert_notification_body1" }}
Status : {{ .Status }}
Problem Host: {{ .CommonLabels.host }}
{{ .CommonAnnotations.summary }}
{{ range .Alerts }}
{{ index .Labels "summary" }}
Alert : {{ index .Labels "alertname" }}
Value : {{ index .Values "B"}}
Time : {{ .StartsAt }}
Link : {{ .GeneratorURL }}
{{ end }}
{{ end }}
'Grafana' 카테고리의 다른 글
grafana-mail 연동 (3) | 2024.10.28 |
---|---|
grafana 설치 (0) | 2024.10.28 |