fuuko/go-neb: Add alertmanager matrix receiver
This commit is contained in:
parent
2897451a65
commit
94b2746018
|
@ -14,7 +14,9 @@
|
||||||
specific service the machine provides.
|
specific service the machine provides.
|
||||||
+ `secrets`: Nix expressions that include information that is not meant to
|
+ `secrets`: Nix expressions that include information that is not meant to
|
||||||
be visible to everyone (e.g. accounts, password hashes, private
|
be visible to everyone (e.g. accounts, password hashes, private
|
||||||
information etc.)
|
information etc.) or secrets for services that don’t provide any other
|
||||||
|
(easy) way of specifying them and whose secrets leaking does not pose a
|
||||||
|
huge threat
|
||||||
* `modules`: Custom modules. Many are activated by default, since I want them
|
* `modules`: Custom modules. Many are activated by default, since I want them
|
||||||
on all systems.
|
on all systems.
|
||||||
* `pkgs`: My nixpkgs overlay
|
* `pkgs`: My nixpkgs overlay
|
||||||
|
|
BIN
machines/fuuko/secrets/go-neb-alertmanager.nix
Normal file
BIN
machines/fuuko/secrets/go-neb-alertmanager.nix
Normal file
Binary file not shown.
|
@ -2,5 +2,6 @@
|
||||||
imports = [
|
imports = [
|
||||||
./synapse.nix
|
./synapse.nix
|
||||||
./mautrix-whatsapp.nix
|
./mautrix-whatsapp.nix
|
||||||
|
./go-neb.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
56
machines/fuuko/services/matrix/go-neb.nix
Normal file
56
machines/fuuko/services/matrix/go-neb.nix
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{ 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" = {
|
||||||
|
text_template = "{{ range .Alerts }}[{{ .Status }}] {{ index .Labels \"alertname\" }}: {{ index .Annotations \"description\" }}\n{{ end }}";
|
||||||
|
html_template = ''
|
||||||
|
{{ range .Alerts }}
|
||||||
|
{{ $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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -51,10 +51,13 @@ in
|
||||||
receivers = [
|
receivers = [
|
||||||
{
|
{
|
||||||
name = "matrix";
|
name = "matrix";
|
||||||
webhook_configs = [
|
webhook_configs = lib.singleton {
|
||||||
# FIXME: Add correct URL
|
url = (lib.elemAt
|
||||||
{ url = "http://matrix-alertmanager:3000/alerts"; }
|
(lib.filter
|
||||||
];
|
({ ID, ... }: ID == "alertmanager_service")
|
||||||
|
config.services.go-neb.config.services)
|
||||||
|
0).Config.webhook_url;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue