From 2a2357142e0a14234fa47220361060ed163e5aaa Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 17 Sep 2026 17:53:16 +0200 Subject: [PATCH] replace sidecar metrics exporter with native metrics endpoint --- .env.sample | 3 +-- README.md | 9 +++------ abra.sh | 6 +++--- compose.metrics.yml | 18 +++--------------- nginx.conf.tmpl | 19 +++++++++++++++++++ release/next | 1 + 6 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 release/next diff --git a/.env.sample b/.env.sample index 3180442..ee2842c 100644 --- a/.env.sample +++ b/.env.sample @@ -109,5 +109,4 @@ DEFAULT_QUOTA="10 GB" #HSTS_PRELOAD=1 # Metrics -# COMPOSE_FILE="$COMPOSE_FILE:compose.metrics.yml" -# SECRET_METRICS_TOKEN_VERSION=v1 # length=32 charset=hex \ No newline at end of file +# COMPOSE_FILE="$COMPOSE_FILE:compose.metrics.yml" \ No newline at end of file diff --git a/README.md b/README.md index d358e48..1ecd2ca 100644 --- a/README.md +++ b/README.md @@ -131,20 +131,17 @@ To disable dashboard app (since it is so corporate): ## Metrics -There is a [metrics exporter](https://github.com/xperimental/nextcloud-exporter) -that can be run as sidecar container, also part of the nextcloud helm charts. +Since Version 33, Nextcloud offers a /metrics endpoint (see [here](https://docs.nextcloud.com/server/stable/admin_manual/configuration_monitoring/index.html)). Its configured via alloys label-based auto-discovery provided by the updated [monitoring-stack](https://git.coopcloud.tech/coop-cloud/monitoring-ng). To enable, uncomment ``` COMPOSE_FILE="$COMPOSE_FILE:compose.metrics.yml" -SECRET_METRICS_TOKEN_VERSION=v1 # length=32 charset=hex ``` -then generate the secret with abra and insert it via `set_metrics_token` +and run `configure_metrics`: ``` -abra app secret generate metrics_token -abra app cmd app set_metrics_token +abra app cmd app configure_metrics ``` ## Upgrading Nextcloud diff --git a/abra.sh b/abra.sh index b31d401..0ee72ad 100644 --- a/abra.sh +++ b/abra.sh @@ -1,7 +1,7 @@ #!/bin/bash export FPM_TUNE_VERSION=v5 -export NGINX_CONF_VERSION=v8 +export NGINX_CONF_VERSION=v9 export MY_CNF_VERSION=v6 export ENTRYPOINT_VERSION=v3 export ENTRYPOINT_WHITEBOARD_VERSION=v1 @@ -195,8 +195,8 @@ upgrade_mariadb() { mariadb-upgrade -p`cat /run/secrets/db_root_password` } -set_metrics_token() { - run_occ "config:app:set serverinfo token --value '$(cat /run/secrets/metrics_token)'" +configure_metrics() { + run_occ "config:system:set openmetrics_allowed_clients 0 --value='10.0.0.0/8'" } # Checks whether this instance looks ready to update to the next Nextcloud diff --git a/compose.metrics.yml b/compose.metrics.yml index b0befdf..334720c 100644 --- a/compose.metrics.yml +++ b/compose.metrics.yml @@ -1,22 +1,10 @@ version: "3.8" services: - app: - secrets: - - metrics_token - metrics: - image: xperimental/nextcloud-exporter:0.9.0 + web: environment: - - NEXTCLOUD_SERVER=https://$DOMAIN - - NEXTCLOUD_AUTH_TOKEN=@/run/secrets/metrics_token - secrets: - - metrics_token - networks: - - proxy + - METRICS_ENABLED=true deploy: labels: - "prometheus.io/scrape=true" - "prometheus.io/port=9205" -secrets: - metrics_token: - external: true - name: ${STACK_NAME}_metrics_token_${SECRET_METRICS_TOKEN_VERSION} \ No newline at end of file + - "prometheus.io/path=/metrics" \ No newline at end of file diff --git a/nginx.conf.tmpl b/nginx.conf.tmpl index fc82a44..74f0777 100644 --- a/nginx.conf.tmpl +++ b/nginx.conf.tmpl @@ -185,4 +185,23 @@ http { try_files $uri $uri/ /index.php$request_uri; } } + + {{ if env "METRICS_ENABLED" }} + server { + listen 9205; + + location = /metrics { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /var/www/html/index.php; + fastcgi_param SCRIPT_NAME /index.php; + fastcgi_param REQUEST_URI /metrics; + fastcgi_param HTTP_HOST {{ env "DOMAIN" }}; + fastcgi_pass php-handler; + } + + location / { + return 404; + } + } + {{ end }} } diff --git a/release/next b/release/next new file mode 100644 index 0000000..c4ede33 --- /dev/null +++ b/release/next @@ -0,0 +1 @@ +add option to scrape native /metrics endpoint via alloys auto-discovery \ No newline at end of file