service/nginx: enable monitoring

This commit is contained in:
Felix Buehler 2023-04-13 20:14:33 +02:00
parent 913cece20f
commit 36bbc03252
2 changed files with 43 additions and 5 deletions

View file

@ -203,6 +203,7 @@ in
; ;
services.nginx = { services.nginx = {
enable = true; enable = true;
statusPage = true; # For monitoring scraping.
recommendedGzipSettings = true; recommendedGzipSettings = true;
recommendedOptimisation = true; recommendedOptimisation = true;
@ -405,5 +406,35 @@ in
}; };
}; };
}; };
# services.prometheus = lib.mkIf cfg.monitoring.enable {
services.prometheus = {
exporters.nginx = {
enable = true;
listenAddress = "127.0.0.1";
};
scrapeConfigs = [
{
job_name = "nginx";
static_configs = [
{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.nginx.port}" ];
labels = {
instance = config.networking.hostName;
};
}
];
}
];
};
services.grafana.provision = {
dashboards.settings.providers = [
{
name = "Nginx";
options.path = pkgs.grafana-dashboards.nginx;
disableDeletion = true;
}
];
};
}; };
} }

View file

@ -33,4 +33,11 @@ in
version = "31"; version = "31";
hash = "sha256-QsRHsnayYRRGc+2MfhaKGYpNdH02PesnR5b50MDzHIg="; hash = "sha256-QsRHsnayYRRGc+2MfhaKGYpNdH02PesnR5b50MDzHIg=";
}; };
nginx = buildGrafanaDashboard {
id = 12708;
pname = "nginx";
version = "1";
hash = "sha256-T1HqWbwt+i/We+Y2B7hcl3CijGxZF5QI38aPcXjk9y0=";
};
}) })