1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-30 11:37:44 +00:00

Add grafana

This commit is contained in:
RGBCube 2024-01-12 19:18:31 +03:00
parent 336c7d3832
commit 3b6d557aea
No known key found for this signature in database
4 changed files with 40 additions and 8 deletions

32
hosts/cube/grafana.nix Normal file
View file

@ -0,0 +1,32 @@
{ config, ulib, ... }: with ulib;
let
inherit (config.networking) domain;
fqdn = "metrics.${domain}";
in serverSystemConfiguration {
age.secrets."cube.mail.password" = {
owner = "grafana";
group = "grafana";
};
services.grafana = enabled {
domain = fqdn;
port = 8999;
settings.security = {
admin_email = "metrics@${domain}";
admin_password = "$__file{${config.age.secrets."cube.mail.password".path}}";
};
};
services.nginx.virtualHosts.${fqdn} = {
forceSSL = true;
useACMEHost = domain;
locations."/" = {
proxyPass = "http://0.0.0.0:${toString config.services.grafana.port}";
proxyWebsockets = true;
};
};
}

View file

@ -32,7 +32,7 @@ in serverSystemConfiguration {
job_name = "mail";
static_configs = [{
labels = [ "mail" ];
labels.job = "mail";
targets = [
"[::]:${toString config.services.prometheus.exporters.dmarc.port}"
"[::]:${toString config.services.prometheus.exporters.dovecot.port}"

View file

@ -1,4 +1,4 @@
{ lib, ulib, pkgs, ... }: with ulib;
{ config, lib, ulib, pkgs, ... }: with ulib;
serverSystemConfiguration {
networking.firewall.allowedTCPPorts = [ 80 443 ];
@ -17,7 +17,7 @@ serverSystemConfiguration {
job_name = "nginx";
static_configs = [{
labels = [ "nginx" ];
labels.job = "nginx";
targets = [
"[::]:${toString config.services.prometheus.exporters.nginxlog.port}"
"[::]:${toString config.services.prometheus.exporters.nginx.port}"

View file

@ -1,4 +1,4 @@
{ ulib, ... }: with ulib;
{ config, ulib, ... }: with ulib;
serverSystemConfiguration {
services.prometheus = enabled {
@ -13,7 +13,7 @@ serverSystemConfiguration {
job_name = "node";
static_configs = [{
labels = [ "node" ];
labels.job = "node";
targets = [ "[::]:${toString config.services.prometheus.exporters.node.port}" ];
}];
}];