add option to expose metrics via nextcloud-exporter #125

Closed
simon wants to merge 0 commits from nextcloud-metrics into main
Owner

This PR adds a metrics sidecar container that's being scraped by the new alloy autodiscovery from https://git.coopcloud.tech/coop-cloud/monitoring-ng
It also comes with an example-dashboard for grafana:

grafik.png

#llm_assisted as I chatted with Claude during development to set everything up.

This PR adds a metrics sidecar container that's being scraped by the new alloy autodiscovery from https://git.coopcloud.tech/coop-cloud/monitoring-ng It also comes with an [example-dashboard](https://git.coopcloud.tech/coop-cloud/monitoring-ng) for grafana: ![grafik.png](/attachments/4811cc86-c5ab-4112-b280-b592d71c02a8) #llm_assisted as I chatted with Claude during development to set everything up.
147 KiB
simon added the enhancement label 2026-09-02 10:09:09 +00:00
simon added 1 commit 2026-09-02 10:09:10 +00:00
add option to expose metrics via nextcloud-exporter
continuous-integration/drone/pr Build is failing
d2560c9304
simon added 1 commit 2026-09-14 16:10:54 +00:00
simon added 1 commit 2026-09-14 16:12:35 +00:00
simon force-pushed nextcloud-metrics from 2bcd83c40b to 768531d1a2 2026-09-14 16:12:35 +00:00 Compare
simon marked the pull request as ready for review 2026-09-14 16:29:18 +00:00
simon requested review from nextcloud-maintainers 2026-09-14 16:29:28 +00:00
ineiti left a comment
Owner

Looks nice - thanks a lot. Some small nitpicks.

Looks nice - thanks a lot. Some small nitpicks.
README.md Outdated
@@ -131,1 +131,4 @@
## 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)
Owner

Nitpick: please respect 80 character limit per line and start new sentences on a new line.

Nitpick: please respect 80 character limit per line and start new sentences on a new line.
simon marked this conversation as resolved
@@ -132,0 +137,4 @@
COMPOSE_FILE="$COMPOSE_FILE:compose.metrics.yml"
SECRET_METRICS_TOKEN_VERSION=v1 # length=32 charset=hex
```
then generate the secret with abra and run
Owner

I prefer the additional line for the very lazy admins:

abra app secret generate <domain> metrics_token
I prefer the additional line for the very lazy admins: ``` abra app secret generate <domain> metrics_token ```
simon marked this conversation as resolved
@@ -0,0 +6,4 @@
metrics:
image: xperimental/nextcloud-exporter:0.9.0
environment:
- NEXTCLOUD_SERVER=https://$DOMAIN
Owner

Uninformed question: shouldn't this point to the docker service name of the nextcloud server? Or will this be called from an external app?

Uninformed question: shouldn't this point to the docker service name of the nextcloud server? Or will this be called from an external app?
Author
Owner

Didn't work for me whereas using $DOMAIN did. Also it's been quite common to do this elsewhere in coop-cloud recipes, so should be fine I think?

Didn't work for me whereas using $DOMAIN did. Also it's been quite common to do this elsewhere in coop-cloud recipes, so should be fine I think?
simon marked this conversation as resolved
simon added 1 commit 2026-09-17 13:25:00 +00:00
dannygroenewegen requested changes 2026-09-17 14:02:01 +00:00
Dismissed
dannygroenewegen left a comment
Owner

Great addition! But: Nextcloud v33 added a metrics endpoint. I think we should use that, no need for a separate container.

https://docs.nextcloud.com/server/stable/admin_manual/configuration_monitoring/index.html

Just tried config:system:set openmetrics_allowed_clients 0 --value="0.0.0.0/0", and this enabled the metrics endpoint for me with Prometheus data. This should then be set to the IP range of the proxy network so Alloy can reach it, without it being exposed publicly. And still needs the compse.metrics.yml to add prometheus.io/scrape labels to the web container.

Great addition! But: Nextcloud v33 added a metrics endpoint. I think we should use that, no need for a separate container. https://docs.nextcloud.com/server/stable/admin_manual/configuration_monitoring/index.html Just tried `config:system:set openmetrics_allowed_clients 0 --value="0.0.0.0/0"`, and this enabled the metrics endpoint for me with Prometheus data. This should then be set to the IP range of the proxy network so Alloy can reach it, without it being exposed publicly. And still needs the compse.metrics.yml to add `prometheus.io/scrape` labels to the web container.
simon added 1 commit 2026-09-17 15:53:27 +00:00
Author
Owner

oh, missed that, but very good point.

had to add some nginx config (with help of Claude) as Nextclouds trusted_domains config blocked alloy otherwise

oh, missed that, but very good point. had to add some nginx config (with help of Claude) as Nextclouds trusted_domains config blocked alloy otherwise
dannygroenewegen requested changes 2026-09-18 09:58:17 +00:00
Dismissed
@@ -0,0 +7,4 @@
labels:
- "prometheus.io/scrape=true"
- "prometheus.io/port=9205"
- "prometheus.io/path=/metrics"
Owner

/metrics is the default path, so this label could be removed.

/metrics is the default path, so this label could be removed.
Author
Owner

I actually prefer making it explicit as its also serves the purpose of documenting which path on which port is used. For me this falls into the "shorter is not always better" category - but on the other hand its not that important, so if you prefer it deleted - I did that now ;)

I actually prefer making it explicit as its also serves the purpose of documenting which path on which port is used. For me this falls into the "shorter is not always better" category - but on the other hand its not that important, so if you prefer it deleted - I did that now ;)
dannygroenewegen marked this conversation as resolved
@@ -188,0 +188,4 @@
{{ if env "METRICS_ENABLED" }}
server {
listen 9205;
Owner

Is there any reason for configuring an extra port for this? To simplify, the whole location = /metrics block could also be put inside the existing port 80 block. And the reference to /var/www/html could be replaced with $document_root/index.php

Is there any reason for configuring an extra port for this? To simplify, the whole `location = /metrics` block could also be put inside the existing port 80 block. And the reference to `/var/www/html` could be replaced with `$document_root/index.php`
Author
Owner

felt safer to me, but I agree its not necessary

felt safer to me, but I agree its not necessary
simon marked this conversation as resolved
simon added 1 commit 2026-09-21 11:04:41 +00:00
simon scheduled this pull request to auto merge when all checks succeed 2026-09-21 14:54:31 +00:00
simon added 1 commit 2026-09-21 14:56:04 +00:00
simon canceled auto merging this pull request when all checks succeed 2026-09-21 14:56:10 +00:00
simon closed this pull request 2026-09-21 14:57:56 +00:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.