add grafana and prometheus

This commit is contained in:
Rouven Seifert 2023-10-29 11:58:56 +01:00
parent 78b1a5761c
commit 862e8ecfb2
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
8 changed files with 94 additions and 20 deletions

View file

@ -0,0 +1,44 @@
{ config, ... }:
let
domain = "monitoring.${config.networking.domain}";
in
{
services.grafana = {
enable = true;
settings = {
server = {
inherit domain;
http_addr = "127.0.0.1";
http_port = 3000;
};
database = {
type = "postgres";
user = "grafana";
host = "/run/postgresql";
};
};
};
services.postgresql = {
enable = true;
ensureUsers = [
{
name = "grafana";
ensurePermissions = {
"DATABASE grafana" = "ALL PRIVILEGES";
};
}
];
ensureDatabases = [ "grafana" ];
};
services.nginx.virtualHosts."${domain}" = {
addSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}/";
proxyWebsockets = true;
};
};
}