dotfiles.nix/nixos/viridian/services/grafana/default.nix

57 lines
1.3 KiB
Nix
Raw Normal View History

2024-08-08 09:02:42 +08:00
{config, ...}: {
2024-06-06 20:38:37 +08:00
# Setup grafana our grafana instance.
services.grafana = {
enable = true;
dataDir = "/srv/services/grafana";
settings = {
server = {
http_addr = "127.0.0.1";
http_port = 3400;
domain = "kanto.dev";
root_url = "https://kanto.dev/grafana/";
serve_from_sub_path = true;
};
database = {
type = "mysql";
name = "grafana";
user = "grafana";
host = "/var/run/mysqld/mysqld.sock";
};
};
};
# Setup our database for grafana.
services.mysql = {
2024-08-08 09:02:42 +08:00
ensureUsers = [
{
name = "grafana";
ensurePermissions = {
"grafana.*" = "ALL PRIVILEGES";
};
}
];
ensureDatabases = ["grafana"];
2024-06-06 20:38:37 +08:00
};
# Setup our traefik router.
services.traefik.dynamicConfigOptions.http.routers = {
grafana = {
rule = "Host(`kanto.dev`)";
entryPoints = [
"websecure"
];
middlewares = [
2024-07-08 22:08:39 +08:00
"internal"
2024-06-06 20:38:37 +08:00
];
service = "grafana";
};
};
# Setup our traefik service.
services.traefik.dynamicConfigOptions.http.services = {
grafana.loadBalancer.servers = [
2024-08-08 09:02:42 +08:00
{url = "http://127.0.0.1:${toString config.services.grafana.settings.server.http_port}";}
2024-06-06 20:38:37 +08:00
];
};
}