diff options
author | sinanmohd <sinan@sinanmohd.com> | 2025-03-09 23:06:42 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2025-03-09 23:06:44 +0530 |
commit | 16269416193b9e41417a27ecb9ef057e22691a5a (patch) | |
tree | 11502178c81c9eac687170780c9e216c37bc5717 /os/kay/modules | |
parent | f566c923d860fb3612c99bf1915c9868e67e2109 (diff) |
kay/observability: init
Diffstat (limited to 'os/kay/modules')
-rw-r--r-- | os/kay/modules/dns/sinanmohd.com.zone | 3 | ||||
-rw-r--r-- | os/kay/modules/observability/default.nix | 4 | ||||
-rw-r--r-- | os/kay/modules/observability/grafana.nix | 48 | ||||
-rw-r--r-- | os/kay/modules/www.nix | 14 |
4 files changed, 68 insertions, 1 deletions
diff --git a/os/kay/modules/dns/sinanmohd.com.zone b/os/kay/modules/dns/sinanmohd.com.zone index 1b16ac5..5c1dddf 100644 --- a/os/kay/modules/dns/sinanmohd.com.zone +++ b/os/kay/modules/dns/sinanmohd.com.zone @@ -2,7 +2,7 @@ $ORIGIN sinanmohd.com. $TTL 2d @ IN SOA ns1 hostmaster ( - 2025030616 ; serial + 2025030900 ; serial 2h ; refresh 5m ; retry 1d ; expire @@ -44,6 +44,7 @@ home IN CNAME @ nixbin IN CNAME @ immich IN CNAME @ sliding IN CNAME @ +grafana IN CNAME @ lia IN A 65.0.3.127 diff --git a/os/kay/modules/observability/default.nix b/os/kay/modules/observability/default.nix new file mode 100644 index 0000000..ff848b8 --- /dev/null +++ b/os/kay/modules/observability/default.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + imports = [ ./grafana.nix ]; +} diff --git a/os/kay/modules/observability/grafana.nix b/os/kay/modules/observability/grafana.nix new file mode 100644 index 0000000..705bdcd --- /dev/null +++ b/os/kay/modules/observability/grafana.nix @@ -0,0 +1,48 @@ +{ config, ... }: +let + domain = "grafana." + config.global.userdata.domain; + user = config.global.userdata.name; + email = config.global.userdata.email; +in +{ + sops.secrets."misc/default_password" = { + owner = "grafana"; + group = "grafana"; + }; + + services = { + postgresql = { + ensureDatabases = [ "grafana" ]; + ensureUsers = [ + { + name = "grafana"; + ensureDBOwnership = true; + } + ]; + }; + + grafana = { + enable = true; + + settings = { + database = { + type = "postgres"; + name = "grafana"; + user = "grafana"; + host = "/run/postgresql"; + }; + + server = { + inherit domain; + enforce_domain = true; + }; + + security = { + admin_user = user; + admin_email = email; + admin_password = "$__file{${config.sops.secrets."misc/default_password".path}}"; + }; + }; + }; + }; +} diff --git a/os/kay/modules/www.nix b/os/kay/modules/www.nix index e73b129..b62a017 100644 --- a/os/kay/modules/www.nix +++ b/os/kay/modules/www.nix @@ -82,6 +82,20 @@ in }; }; + "${config.services.grafana.settings.server.domain}" = defaultOpts // { + extraConfig = '' + proxy_buffering off; + proxy_request_buffering off; + client_max_body_size 0; + ''; + + locations."/" = { + proxyWebsockets = true; + proxyPass = + "http://${config.services.grafana.settings.server.http_addr}:${builtins.toString config.services.grafana.settings.server.http_port}"; + }; + }; + "www.${domain}" = defaultOpts // { root = "/var/www/${domain}"; }; |