making grafana work

This commit is contained in:
quitte 2024-04-29 15:09:56 +02:00
parent 795e3db47f
commit 7526b9273b
2 changed files with 47 additions and 18 deletions

View file

@ -83,6 +83,7 @@
./modules/hedgedoc.nix
./modules/padlist.nix
./modules/nextcloud.nix
./modules/monitoring.nix
./modules/vaultwarden.nix
./modules/forgejo
./modules/kanboard.nix

View file

@ -1,23 +1,51 @@
{ config, pkgs, ... }:
let
domain = "monitoring.${config.networking.domain}";
in {
# grafana configuration
services.grafana = {
enable = true;
port = 2342;
};
services.prometheus = {
enable = true;
port = 9001;
let
domain = "monitoring.${config.networking.domain}";
in
{
# grafana configuration
services.grafana = {
enable = true;
settings = {
server = {
inherit domain;
http_addr = "127.0.0.1";
http_port = 2342;
};
database = {
type = "postgres";
user = "grafana";
host = "/run/postgresql";
};
};
# nginx reverse proxy
services.nginx.virtualHosts.${domain} = {
locations."/" = {
proxyPass = "http://localhost:${toString config.services.grafana.port}";
proxyWebsockets = true;
};
};
services.postgresql = {
enable = true;
ensureUsers = [
{
name = "grafana";
ensurePermissions = {
"DATABASE grafana" = "ALL PRIVILEGES";
};
}
];
ensureDatabases = [ "grafana" ];
};
services.prometheus = {
enable = true;
port = 9001;
};
# nginx reverse proxy
services.nginx.virtualHosts.${domain} = {
locations."/" = {
proxyPass = "http://localhost:${toString config.services.grafana.port}";
proxyWebsockets = true;
};
};
}