2024-02-24 06:52:01 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
let secret = name: "$__file(${config.sops.secrets.${name}.path})";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
../../common/optional/services/nginx.nix
|
|
|
|
./prometheus.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
sops.secrets.grafana_smtp_pass.sopsFile = ../secrets.yaml;
|
|
|
|
sops.secrets.grafana_discord_webhook.sopsFile = ../secrets.yaml;
|
|
|
|
|
|
|
|
# {{{ Main config
|
|
|
|
services.grafana = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
settings = {
|
2024-02-24 06:57:37 +01:00
|
|
|
server.domain = "grafana.moonythm.dev";
|
|
|
|
server.http_port = 8409;
|
2024-02-24 06:52:01 +01:00
|
|
|
|
|
|
|
# {{{ Smtp
|
2024-02-24 07:44:22 +01:00
|
|
|
smtp = rec {
|
2024-02-24 06:52:01 +01:00
|
|
|
enabled = true;
|
2024-02-24 07:36:54 +01:00
|
|
|
host = "smtp.migadu.com:456";
|
2024-02-24 06:52:01 +01:00
|
|
|
from_name = "Grafana";
|
|
|
|
password = secret "grafana_smtp_pass";
|
2024-02-24 07:43:54 +01:00
|
|
|
user = "grafana@orbit.moonythm.dev";
|
|
|
|
from_address = user;
|
2024-02-24 06:52:01 +01:00
|
|
|
};
|
|
|
|
# }}}
|
|
|
|
};
|
|
|
|
|
|
|
|
# {{{ Provisoning
|
|
|
|
provision = {
|
|
|
|
enable = true;
|
2024-02-24 07:36:54 +01:00
|
|
|
|
2024-02-24 07:10:49 +01:00
|
|
|
alerting.contactPoints.settings.contactPoints = [
|
|
|
|
{ name = "email"; }
|
2024-02-24 06:59:53 +01:00
|
|
|
{
|
|
|
|
name = "discord";
|
2024-02-24 07:10:49 +01:00
|
|
|
webhook_configs = [{
|
|
|
|
send_resolved = true;
|
|
|
|
url = secret "grafana_discord_webhook";
|
|
|
|
}];
|
2024-02-24 06:59:53 +01:00
|
|
|
}
|
|
|
|
];
|
2024-02-24 06:52:01 +01:00
|
|
|
|
2024-02-24 06:53:31 +01:00
|
|
|
datasources.settings.datasources = [{
|
2024-02-24 06:52:01 +01:00
|
|
|
name = "Prometheus";
|
|
|
|
type = "prometheus";
|
|
|
|
access = "proxy";
|
|
|
|
url = "prometheus.moonythm.dev";
|
2024-02-24 06:53:31 +01:00
|
|
|
}];
|
2024-02-24 06:52:01 +01:00
|
|
|
};
|
|
|
|
# }}}
|
|
|
|
};
|
|
|
|
# }}}
|
|
|
|
# {{{ Networking & storage
|
2024-02-24 06:57:37 +01:00
|
|
|
services.nginx.virtualHosts.${config.services.grafana.settings.server.domain} =
|
|
|
|
config.satellite.proxy config.services.grafana.settings.server.http_port { };
|
2024-02-24 06:52:01 +01:00
|
|
|
|
2024-02-24 07:19:34 +01:00
|
|
|
environment.persistence."/persist/state".directories = [{
|
|
|
|
directory = config.services.grafana.dataDir;
|
|
|
|
user = "grafana";
|
|
|
|
group = "grafana";
|
|
|
|
}];
|
2024-02-24 06:52:01 +01:00
|
|
|
# }}}
|
|
|
|
}
|