-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/prometheus-exporter: add php-fpm
- Loading branch information
1 parent
ca2bf7e
commit 3e4d146
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ let | |
"nut" | ||
"openldap" | ||
"openvpn" | ||
"php-fpm" | ||
"pihole" | ||
"postfix" | ||
"postgres" | ||
|
63 changes: 63 additions & 0 deletions
63
nixos/modules/services/monitoring/prometheus/exporters/php-fpm.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ config | ||
, lib | ||
, pkgs | ||
, options | ||
}: | ||
|
||
let | ||
logPrefix = "services.prometheus.exporter.php-fpm"; | ||
cfg = config.services.prometheus.exporters.php-fpm; | ||
in { | ||
port = 9253; | ||
extraOpts = { | ||
telemetryPath = lib.mkOption { | ||
type = lib.types.str; | ||
default = "/metrics"; | ||
description = lib.mdDoc '' | ||
Path under which to expose metrics. | ||
''; | ||
}; | ||
|
||
environmentFile = lib.mkOption { | ||
type = lib.types.nullOr lib.types.path; | ||
default = null; | ||
example = "/root/prometheus-php-fpm-exporter.env"; | ||
description = lib.mdDoc '' | ||
Environment file as defined in {manpage}`systemd.exec(5)`. | ||
Secrets may be passed to the service without adding them to the | ||
world-readable Nix store, by specifying placeholder variables as | ||
the option value in Nix and setting these variables accordingly in the | ||
environment file. | ||
Environment variables from this file will be interpolated into the | ||
config file using envsubst with this syntax: | ||
`$ENVIRONMENT ''${VARIABLE}` | ||
For variables to use see [options and defaults](https://github.com/hipages/php-fpm_exporter#options-and-defaults). | ||
The main use is to set the PHP_FPM_SCRAPE_URI that indicate how to connect to PHP-FPM process. | ||
``` | ||
# Content of the environment file | ||
PHP_FPM_SCRAPE_URI="unix:///tmp/php.sock;/status" | ||
``` | ||
Note that this file needs to be available on the host on which | ||
this exporter is running. | ||
''; | ||
}; | ||
}; | ||
|
||
serviceOpts = { | ||
serviceConfig = { | ||
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) [ cfg.environmentFile ]; | ||
ExecStart = '' | ||
${pkgs.prometheus-php-fpm-exporter}/bin/php-fpm_exporter server \ | ||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ | ||
--web.telemetry-path ${cfg.telemetryPath} \ | ||
${lib.concatStringsSep " \\\n " cfg.extraFlags} | ||
''; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters