fix phpfpm prometheus exporter

This commit is contained in:
ibizaman 2024-12-23 23:26:42 +01:00 committed by Pierre Penninckx
parent a784c08761
commit 538c0a08cd

View file

@ -776,9 +776,21 @@ in
user = "nginx"; user = "nginx";
port = cfg.phpFpmPrometheusExporter.port; port = cfg.phpFpmPrometheusExporter.port;
listenAddress = "127.0.0.1"; listenAddress = "127.0.0.1";
environmentFile = pkgs.writeText "phpFpmExporterEnvFiles" '' extraFlags = [
PHP_FPM_SCRAPE_URI=unix://${config.services.phpfpm.pools.nextcloud.socket} "--phpfpm.scrape-uri=tcp://127.0.0.1:${toString (cfg.phpFpmPrometheusExporter.port -1)}/status?full"
''; ];
};
services.nextcloud = {
poolSettings = {
"pm.status_path" = "/status";
# Need to use TCP connection to get status.
# I couldn't get PHP-FPM exporter to work with a unix socket.
#
# I also tried to server the status page at /status.php
# but fcgi doesn't like the returned headers.
"pm.status_listen" = "127.0.0.1:${toString (cfg.phpFpmPrometheusExporter.port -1)}";
};
}; };
services.prometheus.scrapeConfigs = [ services.prometheus.scrapeConfigs = [
@ -786,6 +798,10 @@ in
job_name = "phpfpm-nextcloud"; job_name = "phpfpm-nextcloud";
static_configs = [{ static_configs = [{
targets = ["127.0.0.1:${toString cfg.phpFpmPrometheusExporter.port}"]; targets = ["127.0.0.1:${toString cfg.phpFpmPrometheusExporter.port}"];
labels = {
"hostname" = config.networking.hostName;
"domain" = cfg.domain;
};
}]; }];
} }
]; ];