add phpfpm prometheus exporter
This commit is contained in:
parent
3fc1e61b30
commit
9a7bcd374b
3 changed files with 85 additions and 0 deletions
|
|
@ -1418,6 +1418,15 @@
|
||||||
"services-nextcloudserver-options-shb.nextcloud.phpFpmPoolSettings": [
|
"services-nextcloudserver-options-shb.nextcloud.phpFpmPoolSettings": [
|
||||||
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.phpFpmPoolSettings"
|
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.phpFpmPoolSettings"
|
||||||
],
|
],
|
||||||
|
"services-nextcloudserver-options-shb.nextcloud.phpFpmPrometheusExporter": [
|
||||||
|
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.phpFpmPrometheusExporter"
|
||||||
|
],
|
||||||
|
"services-nextcloudserver-options-shb.nextcloud.phpFpmPrometheusExporter.enable": [
|
||||||
|
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.phpFpmPrometheusExporter.enable"
|
||||||
|
],
|
||||||
|
"services-nextcloudserver-options-shb.nextcloud.phpFpmPrometheusExporter.port": [
|
||||||
|
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.phpFpmPrometheusExporter.port"
|
||||||
|
],
|
||||||
"services-nextcloudserver-options-shb.nextcloud.port": [
|
"services-nextcloudserver-options-shb.nextcloud.port": [
|
||||||
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.port"
|
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.port"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,27 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
phpFpmPrometheusExporter = lib.mkOption {
|
||||||
|
description = "Settings for exporting";
|
||||||
|
default = {};
|
||||||
|
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = lib.mkOption {
|
||||||
|
description = "Enable export of php-fpm metrics to Prometheus.";
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
port = lib.mkOption {
|
||||||
|
description = "Port on which the exporter will listen.";
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 8300;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
apps = lib.mkOption {
|
apps = lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
Applications to enable in Nextcloud. Enabling an application here will also configure
|
Applications to enable in Nextcloud. Enabling an application here will also configure
|
||||||
|
|
@ -749,6 +770,27 @@ in
|
||||||
systemd.services.nextcloud-setup.after = cfg.mountPointServices;
|
systemd.services.nextcloud-setup.after = cfg.mountPointServices;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(lib.mkIf cfg.phpFpmPrometheusExporter.enable {
|
||||||
|
services.prometheus.exporters.php-fpm = {
|
||||||
|
enable = true;
|
||||||
|
user = "nginx";
|
||||||
|
port = cfg.phpFpmPrometheusExporter.port;
|
||||||
|
listenAddress = "127.0.0.1";
|
||||||
|
environmentFile = pkgs.writeText "phpFpmExporterEnvFiles" ''
|
||||||
|
PHP_FPM_SCRAPE_URI=unix://${config.services.phpfpm.pools.nextcloud.socket}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "phpfpm-nextcloud";
|
||||||
|
static_configs = [{
|
||||||
|
targets = ["127.0.0.1:${toString cfg.phpFpmPrometheusExporter.port}"];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
(lib.mkIf (cfg.enable && cfg.apps.onlyoffice.enable) {
|
(lib.mkIf (cfg.enable && cfg.apps.onlyoffice.enable) {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,24 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
prometheus = { config, ... }: {
|
||||||
|
shb.nextcloud = {
|
||||||
|
phpFpmPrometheusExporter.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
prometheusTestScript = { nodes, ... }:
|
||||||
|
''
|
||||||
|
server.wait_for_open_unix_socket("${nodes.server.services.phpfpm.pools.nextcloud.socket}")
|
||||||
|
server.wait_for_open_port(${toString nodes.server.services.prometheus.exporters.php-fpm.port})
|
||||||
|
with subtest("prometheus"):
|
||||||
|
response = server.succeed(
|
||||||
|
"curl -sSf "
|
||||||
|
+ " http://localhost:${toString nodes.server.services.prometheus.exporters.php-fpm.port}/metrics"
|
||||||
|
)
|
||||||
|
print(response)
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
basic = pkgs.testers.runNixOSTest {
|
basic = pkgs.testers.runNixOSTest {
|
||||||
|
|
@ -343,4 +361,20 @@ in
|
||||||
|
|
||||||
testScript = commonTestScript.access;
|
testScript = commonTestScript.access;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
prometheus = pkgs.testers.runNixOSTest {
|
||||||
|
name = "nextcloud_prometheus";
|
||||||
|
|
||||||
|
nodes.server = { config, ... }: {
|
||||||
|
imports = [
|
||||||
|
base
|
||||||
|
basic
|
||||||
|
prometheus
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nodes.client = {};
|
||||||
|
|
||||||
|
testScript = prometheusTestScript;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue