1{ 2 config, 3 lib, 4 pkgs, 5 options, 6 ... 7}: 8 9let 10 logPrefix = "services.prometheus.exporter.php-fpm"; 11 cfg = config.services.prometheus.exporters.php-fpm; 12in 13{ 14 port = 9253; 15 extraOpts = { 16 package = lib.mkPackageOption pkgs "prometheus-php-fpm-exporter" { }; 17 18 telemetryPath = lib.mkOption { 19 type = lib.types.str; 20 default = "/metrics"; 21 description = '' 22 Path under which to expose metrics. 23 ''; 24 }; 25 26 environmentFile = lib.mkOption { 27 type = lib.types.nullOr lib.types.path; 28 default = null; 29 example = "/root/prometheus-php-fpm-exporter.env"; 30 description = '' 31 Environment file as defined in {manpage}`systemd.exec(5)`. 32 33 Secrets may be passed to the service without adding them to the 34 world-readable Nix store, by specifying placeholder variables as 35 the option value in Nix and setting these variables accordingly in the 36 environment file. 37 38 Environment variables from this file will be interpolated into the 39 config file using envsubst with this syntax: 40 `$ENVIRONMENT ''${VARIABLE}` 41 42 For variables to use see [options and defaults](https://github.com/hipages/php-fpm_exporter#options-and-defaults). 43 44 The main use is to set the PHP_FPM_SCRAPE_URI that indicate how to connect to PHP-FPM process. 45 46 ``` 47 # Content of the environment file 48 PHP_FPM_SCRAPE_URI="unix:///tmp/php.sock;/status" 49 ``` 50 51 Note that this file needs to be available on the host on which 52 this exporter is running. 53 ''; 54 }; 55 }; 56 57 serviceOpts = { 58 serviceConfig = { 59 EnvironmentFile = lib.mkIf (cfg.environmentFile != null) [ cfg.environmentFile ]; 60 ExecStart = '' 61 ${lib.getExe cfg.package} server \ 62 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ 63 --web.telemetry-path ${cfg.telemetryPath} \ 64 ${lib.concatStringsSep " \\\n " cfg.extraFlags} 65 ''; 66 }; 67 }; 68}