2024-02-24 06:52:01 +01:00
|
|
|
{ config, pkgs, ... }:
|
2024-02-24 08:22:35 +01:00
|
|
|
let
|
|
|
|
secret = name: "$__file{${config.sops.secrets.${name}.path}}";
|
|
|
|
sopsSettings = {
|
|
|
|
sopsFile = ../secrets.yaml;
|
2024-02-24 08:26:09 +01:00
|
|
|
owner = "grafana";
|
2024-02-24 08:22:35 +01:00
|
|
|
};
|
2024-02-24 06:52:01 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
../../common/optional/services/nginx.nix
|
|
|
|
./prometheus.nix
|
|
|
|
];
|
|
|
|
|
2024-02-24 08:22:35 +01:00
|
|
|
sops.secrets.grafana_smtp_pass = sopsSettings;
|
|
|
|
sops.secrets.grafana_discord_webhook = sopsSettings;
|
2024-02-24 06:52:01 +01:00
|
|
|
|
|
|
|
# {{{ Main config
|
|
|
|
services.grafana = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
settings = {
|
2024-02-24 08:40:01 +01:00
|
|
|
server = rec {
|
|
|
|
domain = "grafana.moonythm.dev";
|
|
|
|
root_url = "https://${domain}";
|
|
|
|
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 08:22:35 +01:00
|
|
|
|
2024-02-24 07:43:54 +01:00
|
|
|
user = "grafana@orbit.moonythm.dev";
|
2024-02-24 08:22:35 +01:00
|
|
|
from_name = "Grafana";
|
2024-02-24 07:43:54 +01:00
|
|
|
from_address = user;
|
2024-02-24 08:22:35 +01:00
|
|
|
|
|
|
|
host = "smtp.migadu.com:465";
|
|
|
|
password = secret "grafana_smtp_pass";
|
2024-02-24 08:05:17 +01:00
|
|
|
startTLS_policy = "NoStartTLS";
|
2024-02-24 06:52:01 +01:00
|
|
|
};
|
|
|
|
# }}}
|
|
|
|
};
|
|
|
|
|
|
|
|
# {{{ Provisoning
|
|
|
|
provision = {
|
|
|
|
enable = true;
|
2024-02-24 07:36:54 +01:00
|
|
|
|
2024-02-24 08:14:41 +01:00
|
|
|
# https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/
|
2024-02-24 08:32:44 +01:00
|
|
|
alerting.contactPoints.settings.contactPoints = [{
|
|
|
|
name = "main";
|
|
|
|
receivers = [
|
|
|
|
{
|
|
|
|
uid = "main_discord";
|
|
|
|
type = "discord";
|
|
|
|
settings.url = secret "grafana_discord_webhook";
|
2024-02-24 08:38:06 +01:00
|
|
|
settings.message = ''
|
|
|
|
@everyone ✨ An issue occured :O ✨
|
|
|
|
{{ template "default.message" . }}
|
|
|
|
'';
|
2024-02-24 08:32:44 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
uid = "main_email";
|
|
|
|
type = "email";
|
|
|
|
settings.addresses = "colimit@moonythm.dev";
|
|
|
|
}
|
2024-02-24 08:14:41 +01:00
|
|
|
];
|
2024-02-24 08:32:44 +01:00
|
|
|
}];
|
2024-02-24 06:52:01 +01:00
|
|
|
|
2024-02-24 08:45:06 +01:00
|
|
|
alerting.policies.settings.policies = [{
|
|
|
|
receiver = "main";
|
|
|
|
}];
|
|
|
|
|
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
|
|
|
# }}}
|
|
|
|
}
|