2021-04-02 17:46:07 +02:00
|
|
|
{ config, ... }:
|
|
|
|
let
|
|
|
|
synapseCfg = config.services.matrix-synapse;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services.go-neb = rec {
|
|
|
|
enable = true;
|
|
|
|
bindAddress = "127.0.0.1:8010";
|
|
|
|
baseUrl = "http://${bindAddress}";
|
|
|
|
config = {
|
|
|
|
clients = [
|
|
|
|
({
|
|
|
|
UserID = "@alertmanager:${synapseCfg.server_name}";
|
|
|
|
HomeserverURL = synapseCfg.public_baseurl;
|
|
|
|
Sync = false;
|
|
|
|
AutoJoinRooms = false;
|
|
|
|
DisplayName = "Prometheus Alertmanager";
|
|
|
|
} // (import ../../secrets/go-neb-alertmanager.nix)) # AccessToken and DeviceID
|
|
|
|
];
|
|
|
|
services = [
|
|
|
|
{
|
|
|
|
ID = "alertmanager_service";
|
|
|
|
Type = "alertmanager";
|
|
|
|
UserID = "@alertmanager:${synapseCfg.server_name}";
|
|
|
|
Config = {
|
|
|
|
webhook_url = "${baseUrl}/services/hooks/YWxlcnRtYW5hZ2VyX3NlcnZpY2U";
|
|
|
|
rooms = {
|
|
|
|
"!ceigaGYfREXXSeLFiH:sbruder.de" = {
|
2021-04-08 10:04:30 +02:00
|
|
|
text_template = "{{ range .Alerts }}{{ if eq .Status \"firing\" }}@room {{ end }}[{{ .Status }}] {{ index .Labels \"alertname\" }}: {{ index .Annotations \"description\" }}\n{{ end }}";
|
2021-04-02 17:46:07 +02:00
|
|
|
html_template = ''
|
|
|
|
{{ range .Alerts }}
|
2021-04-08 10:04:30 +02:00
|
|
|
{{- if eq .Status "firing" }}@room {{ end -}}
|
2021-04-02 17:46:07 +02:00
|
|
|
{{ $severity := index .Labels "severity" }}
|
|
|
|
<font{{ if eq .Status "firing" -}}
|
|
|
|
{{- if eq $severity "critical" }} color="red"
|
|
|
|
{{- else if eq $severity "warning" }} color="orange"
|
|
|
|
{{- end -}}
|
|
|
|
{{- else }} color="green"
|
|
|
|
{{- end }}>
|
|
|
|
<strong>{{ if eq .Status "firing" -}}
|
|
|
|
[firing{{ if ne $severity "" }} - {{ $severity }}{{ end }}]
|
|
|
|
{{- else -}}
|
|
|
|
[resolved]
|
|
|
|
{{- end }}</strong>
|
|
|
|
</font>
|
|
|
|
{{ index .Labels "alertname" }}: {{ index .Annotations "description" }} <a href="{{ .GeneratorURL }}">source</a><br/>
|
|
|
|
{{ end }}
|
|
|
|
'';
|
|
|
|
msg_type = "m.text";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|