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

91 lines
2.1 KiB
Nix
Raw Normal View History

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;
user = "grafana";
group = "grafana";
};
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 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 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/
alerting.contactPoints.settings = {
deleteContactPoints = [
{ uid = "main_discord"; }
{ uid = "main_email"; }
];
contactPoints = [{
name = "main";
receivers = [
{
uid = "main_discord";
type = "discord";
settings.url = secret "grafana_discord_webhook";
}
{
uid = "main_email";
type = "email";
settings.addresses = "colimit@moonythm.dev";
}
];
}];
};
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
environment.persistence."/persist/state".directories = [{
directory = config.services.grafana.dataDir;
user = "grafana";
group = "grafana";
}];
2024-02-24 06:52:01 +01:00
# }}}
}