mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-29 04:07:02 +02:00
feat: update alertmanager message template
This commit is contained in:
@@ -17,6 +17,11 @@
|
|||||||
rule = [
|
rule = [
|
||||||
"${./alert_rules}/*.yml"
|
"${./alert_rules}/*.yml"
|
||||||
];
|
];
|
||||||
|
# https://docs.victoriametrics.com/victoriametrics/vmalert/#link-to-alert-source
|
||||||
|
# Set this two args to generate the correct `.GeneratorURL`
|
||||||
|
"external.url" = "https://grafana.writefor.fun";
|
||||||
|
"external.alert.source" =
|
||||||
|
''explore?left={"datasource":"{{ if eq .Type \"vlogs\" }}VictoriaLogs{{ else }}VictoriaMetrics{{ end }}","queries":[{"expr":{{ .Expr|jsonEscape|queryEscape }},"refId":"A"}],"range":{"from":"{{ .ActiveAt.UnixMilli }}","to":"now"}}'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,9 +63,9 @@
|
|||||||
"type"
|
"type"
|
||||||
"host"
|
"host"
|
||||||
];
|
];
|
||||||
group_wait = "5m";
|
group_wait = "3m"; # wait for other alerts to "group by" before send notification
|
||||||
group_interval = "5m";
|
group_interval = "5m"; # wait for an interval, before send a new alert in the same group
|
||||||
repeat_interval = "4h";
|
repeat_interval = "5h"; # avoiding repeating reminders too frequently
|
||||||
}
|
}
|
||||||
# {
|
# {
|
||||||
# # Route only prod env's critical alerts to email (most severe alerts)
|
# # Route only prod env's critical alerts to email (most severe alerts)
|
||||||
@@ -102,28 +107,30 @@
|
|||||||
send_resolved = true;
|
send_resolved = true;
|
||||||
# Disable notifications for resolved alerts
|
# Disable notifications for resolved alerts
|
||||||
disable_notifications = false;
|
disable_notifications = false;
|
||||||
# Parse mode for the message
|
# Telegram's MarkdownV2 & Markdown are all very painful, we use html instead.
|
||||||
parse_mode = "Markdown";
|
# https://core.telegram.org/bots/api#formatting-options
|
||||||
|
parse_mode = "HTML";
|
||||||
# Message template
|
# Message template
|
||||||
message = ''
|
message = ''
|
||||||
*Alert:* {{ .GroupLabels.alertname }}
|
{{- if eq .Status "firing" }}
|
||||||
*Status:* {{ .Status }}
|
🟡 <b>告警触发</b> {{ .CommonLabels.alertname }} [{{ index .CommonLabels "severity" | title }}]
|
||||||
*Severity:* {{ .CommonLabels.severity }}
|
{{- else }}
|
||||||
{{ if .GroupLabels.namespace }}*Namespace:* {{ .GroupLabels.namespace }}{{ end }}
|
🟢 <b>告警恢复</b> {{ .CommonLabels.alertname }} [{{ index .CommonLabels "severity" | title }}]
|
||||||
{{ if .GroupLabels.pod }}*Pod:* {{ .GroupLabels.pod }}{{ end }}
|
{{- end }}
|
||||||
{{ if .GroupLabels.job }}*Job:* {{ .GroupLabels.job }}{{ end }}
|
|
||||||
{{ if .GroupLabels.host }}*Host:* {{ .GroupLabels.host }}{{ end }}
|
|
||||||
|
|
||||||
{{ range .Alerts }}
|
{{- range .Alerts }}
|
||||||
*Alert:* {{ .Annotations.summary }}
|
|
||||||
*Description:* {{ .Annotations.description }}
|
📊 <b>详情:</b>
|
||||||
{{ if .Labels.instance }}*Instance:* {{ .Labels.instance }}{{ end }}
|
• <b>告警组</b>: {{ .Labels.alertgroup }}
|
||||||
{{ if .Labels.container }}*Container:* {{ .Labels.container }}{{ end }}
|
• <b>等级</b>: {{ if eq .Labels.severity "critical" }}🔴{{ else }}🟡 {{ end }} {{ .Labels.severity | title }}
|
||||||
*Started:* {{ .StartsAt.Format "2006-01-02 15:04:05" }}
|
• <b>查询</b>: <a href="{{ .GeneratorURL }}">Grafana Explore</a>
|
||||||
{{ if .EndsAt }}
|
• <b>触发值</b>: {{ with .Annotations.value }}{{ . }}{{ else }}N/A{{ end }}
|
||||||
*Ended:* {{ .EndsAt.Format "2006-01-02 15:04:05" }}
|
• <b>Env</b>: {{ with .Labels.env }}{{ . }}{{ else }}N/A{{ end }}
|
||||||
{{ end }}
|
• <b>Cluster</b>: {{ with .Labels.cluster }}{{ . }}{{ else }}N/A{{ end }}
|
||||||
{{ end }}
|
• <b>Namespace</b>: {{ with .Labels.namespace }}{{ . }}{{ else }}N/A{{ end }}
|
||||||
|
• <b>标签</b>: {{ range .Labels.SortedPairs }}{{ .Name }}={{ .Value }},{{ end }}
|
||||||
|
• <b>触发时间</b>: {{ .StartsAt.Format "2006-01-02 15:04:05" }}
|
||||||
|
{{- end }}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user