1
Fork 0
satellite/hosts/nixos/lapetus/services/grafana.nix

98 lines
2.3 KiB
Nix
Raw Permalink Normal View History

2024-02-24 06:52:01 +01:00
{ config, pkgs, ... }:
2024-02-24 08:22:35 +01:00
let
2024-06-13 15:47:36 +02:00
port = config.satellite.ports.grafana;
2024-02-24 08:22:35 +01:00
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
{
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 = {
server = rec {
2024-06-13 15:47:36 +02:00
domain = config.satellite.nginx.at.grafana.host;
root_url = "https://${domain}";
2024-06-13 15:47:36 +02:00
http_port = port;
};
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:52:01 +01:00
alerting.contactPoints.settings = {
apiVersion = 1;
contactPoints = [{
name = "main";
receivers = [
{
uid = "main_discord";
type = "discord";
settings.url = secret "grafana_discord_webhook";
settings.message = ''
@everyone An issue occured :O
{{ template "default.message" . }}
'';
}
{
uid = "main_email";
type = "email";
settings.addresses = "colimit@moonythm.dev";
}
];
}];
};
2024-02-24 06:52:01 +01:00
2024-02-24 08:52:01 +01:00
alerting.policies.settings = {
apiVersion = 1;
policies = [{
receiver = "main";
}];
};
2024-02-24 08:45:06 +01:00
2024-02-24 08:52:01 +01:00
datasources.settings = {
apiVersion = 1;
datasources = [{
name = "Prometheus";
type = "prometheus";
access = "proxy";
url = "https://prometheus.moonythm.dev";
}];
};
2024-02-24 06:52:01 +01:00
};
# }}}
};
# }}}
# {{{ Networking & storage
2024-06-13 15:47:36 +02:00
satellite.nginx.at.grafana.port = port;
2024-02-24 06:52:01 +01:00
environment.persistence."/persist/state".directories = [{
directory = config.services.grafana.dataDir;
user = "grafana";
group = "grafana";
}];
2024-02-24 06:52:01 +01:00
# }}}
}