From 1d6ec8cf38e77c84cb5d8c450d08bbe18b7e86c5 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 14 Sep 2026 18:08:09 +0200 Subject: [PATCH] add nextcloud metrics exporter --- .env.sample | 4 ++++ README.md | 11 +++++++++++ abra.sh | 4 ++++ compose.metrics.yml | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 compose.metrics.yml diff --git a/.env.sample b/.env.sample index 3e84dc5..3180442 100644 --- a/.env.sample +++ b/.env.sample @@ -107,3 +107,7 @@ DEFAULT_QUOTA="10 GB" #HSTS_ENABLED=1 # Uncomment this line to add the `preload` part #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 diff --git a/README.md b/README.md index 897cc0c..7fae4f8 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,17 @@ To disable dashboard app (since it is so corporate): - Configure a `defaultapp` in your `config.php` or use [apporder](https://apps.nextcloud.com/apps/apporder) +## 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. 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 run +`abra app cmd app set_metrics_token` + ## Upgrading Nextcloud Upgrading Nextcloud can be a hair raising experiance. They diff --git a/abra.sh b/abra.sh index f201ab7..fa4c797 100644 --- a/abra.sh +++ b/abra.sh @@ -350,3 +350,7 @@ check_major_upgrade() { return 1 fi } + +set_metrics_token() { + run_occ "config:app:set serverinfo token --value '$(cat /run/secrets/metrics_token)'" +} \ No newline at end of file diff --git a/compose.metrics.yml b/compose.metrics.yml new file mode 100644 index 0000000..b0befdf --- /dev/null +++ b/compose.metrics.yml @@ -0,0 +1,22 @@ +version: "3.8" +services: + app: + secrets: + - metrics_token + metrics: + image: xperimental/nextcloud-exporter:0.9.0 + environment: + - NEXTCLOUD_SERVER=https://$DOMAIN + - NEXTCLOUD_AUTH_TOKEN=@/run/secrets/metrics_token + secrets: + - metrics_token + networks: + - proxy + 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