mirror of
https://github.com/kmein/niveum
synced 2026-03-23 13:21:06 +01:00
alertmanager: alert lassulus for mastodon outtime
This commit is contained in:
@@ -3,11 +3,13 @@
|
|||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
lokiConfig = import ./loki.nix;
|
lokiConfig = import ./loki.nix;
|
||||||
blackboxConfig = import ./blackbox.nix;
|
blackboxConfig = import ./blackbox.nix;
|
||||||
inherit (import ../../../lib) restic;
|
inherit (import ../../../lib) restic;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
services.grafana = {
|
services.grafana = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
@@ -80,9 +82,11 @@ in {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
services.prometheus.rules = let
|
services.prometheus.rules =
|
||||||
|
let
|
||||||
diskFreeThreshold = 10;
|
diskFreeThreshold = 10;
|
||||||
in [
|
in
|
||||||
|
[
|
||||||
(builtins.toJSON {
|
(builtins.toJSON {
|
||||||
groups = [
|
groups = [
|
||||||
{
|
{
|
||||||
@@ -181,6 +185,12 @@ in {
|
|||||||
expr = "time() - node_boot_time_seconds < 300";
|
expr = "time() - node_boot_time_seconds < 300";
|
||||||
annotations.description = "{{$labels.instance}} rebooted";
|
annotations.description = "{{$labels.instance}} rebooted";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
alert = "Mastodon";
|
||||||
|
expr = ''probe_success{instance="https://social.krebsco.de"}'';
|
||||||
|
for = "5m";
|
||||||
|
annotations.description = "Mastodon instance {{$labels.instance}} is down";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
alert = "ProbeFailed";
|
alert = "ProbeFailed";
|
||||||
expr = "probe_success == 0";
|
expr = "probe_success == 0";
|
||||||
@@ -217,7 +227,6 @@ in {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
# ref https://github.com/Mic92/dotfiles/blob/f44bac5dd6970ed3fbb4feb906917331ec3c2be5/machines/eva/modules/prometheus/default.nix
|
# ref https://github.com/Mic92/dotfiles/blob/f44bac5dd6970ed3fbb4feb906917331ec3c2be5/machines/eva/modules/prometheus/default.nix
|
||||||
systemd.services.matrix-hook = {
|
systemd.services.matrix-hook = {
|
||||||
description = "Matrix Hook";
|
description = "Matrix Hook";
|
||||||
@@ -246,6 +255,33 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.matrix-hook-lassulus = {
|
||||||
|
description = "Matrix Hook";
|
||||||
|
after = [ "network.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
environment = {
|
||||||
|
HTTP_ADDRESS = "[::1]";
|
||||||
|
HTTP_PORT = "9089";
|
||||||
|
MX_HOMESERVER = "https://matrix.4d2.org";
|
||||||
|
MX_ID = "@lakai:4d2.org";
|
||||||
|
MX_ROOMID = "!MJAGqBAOKZGMywzwkI:lassul.us";
|
||||||
|
MX_MSG_TEMPLATE = "${pkgs.matrix-hook}/message.html.tmpl";
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
EnvironmentFile = [
|
||||||
|
# format: MX_TOKEN=<token>
|
||||||
|
config.age.secrets.matrix-token-lakai-env.path
|
||||||
|
];
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${pkgs.matrix-hook}/bin/matrix-hook";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "10";
|
||||||
|
DynamicUser = true;
|
||||||
|
User = "matrix-hook";
|
||||||
|
Group = "matrix-hook";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
matrix-token-lakai-env.file = ../../../secrets/matrix-token-lakai-env.age;
|
matrix-token-lakai-env.file = ../../../secrets/matrix-token-lakai-env.age;
|
||||||
};
|
};
|
||||||
@@ -260,8 +296,23 @@ in {
|
|||||||
group_wait = "30s";
|
group_wait = "30s";
|
||||||
repeat_interval = "24h";
|
repeat_interval = "24h";
|
||||||
receiver = "matrix";
|
receiver = "matrix";
|
||||||
|
routes = [
|
||||||
|
{
|
||||||
|
receiver = "lassulus";
|
||||||
|
matchers = [ "alertname = \"Mastodon\"" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
receivers = [
|
receivers = [
|
||||||
|
{
|
||||||
|
name = "lassulus";
|
||||||
|
webhook_configs = [
|
||||||
|
{
|
||||||
|
url = "http://localhost:9089/alert";
|
||||||
|
max_alerts = 5;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "matrix";
|
name = "matrix";
|
||||||
webhook_configs = [
|
webhook_configs = [
|
||||||
|
|||||||
Reference in New Issue
Block a user