Skip to content

feat(openmetrics): introduce OpenMetrics exporter - #57165

Merged
Altahrim merged 4 commits into
masterfrom
feat/openmetrics
Jan 7, 2026
Merged

feat(openmetrics): introduce OpenMetrics exporter#57165
Altahrim merged 4 commits into
masterfrom
feat/openmetrics

Conversation

@Altahrim

@AltahrimAltahrim commented Dec 18, 2025

Copy link
Copy Markdown
Collaborator

Summary

Introduce OpenMetrics endpoint featuring Nextcloud metrics.

It allows to get statistics about the Nextcloud instance but not about hardware (some exporters are already doing that very well). For example: number of files, shares or active users.

It's extensible so every app will be able to expose it's own metrics.

Test

Access it on /metrics (or index.php/metrics depending of configuration)

TODO

  • OpenAPI extractor

Checklist

@AltahrimAltahrim added this to the Nextcloud 33 milestone Dec 18, 2025
@AltahrimAltahrim self-assigned this Dec 18, 2025
@AltahrimAltahrim added 2. developing Work in progress php Pull requests that update Php code feature: monitoring Features related to observability labels Dec 18, 2025
@github-project-automationgithub-project-automationBot moved this to 🏗️ In progress in 📁 Files teamDec 18, 2025
@Altahrim
Altahrimforce-pushed the feat/openmetrics branch 2 times, most recently from 9e91442 to 30dd586CompareDecember 19, 2025 08:44
@Altahrim
Altahrimforce-pushed the feat/openmetrics branch 4 times, most recently from f043ff3 to 56d654bCompareJanuary 6, 2026 09:59
Comment threadapps/comments/appinfo/info.xml Outdated
Comment threadlib/public/OpenMetrics/MetricTypes.php Outdated
Comment threadapps/comments/lib/OpenMetrics/Comments.php Outdated
Comment threadapps/files_sharing/appinfo/info.xml Outdated
Comment threadapps/files_sharing/lib/OpenMetrics/SharesCount.php Outdated
Comment threadcore/Controller/OpenMetricsController.php Outdated
Comment threadlib/private/OpenMetrics/Exporter.php Outdated
Comment threadlib/private/OpenMetrics/Exporters/ActiveUsers.php Outdated
Comment threadlib/private/OpenMetrics/Exporters/Cached.php Outdated
Comment threadlib/private/OpenMetrics/Exporters/Maintenance.php
@AltahrimAltahrim added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 6, 2026
@Altahrim
Altahrim marked this pull request as ready for review January 6, 2026 13:48
@Altahrim
Altahrim requested review from salmart-dev and yemkareems and removed request for a teamJanuary 6, 2026 13:48
@icewind1991

Copy link
Copy Markdown
Member

Some of these (counting files) are going to have a non-trivial cost, might be worth having a way to toggle individual metrics.

@Altahrim

Copy link
Copy Markdown
CollaboratorAuthor

Some of these (counting files) are going to have a non-trivial cost, might be worth having a way to toggle individual metrics.

You are right :) That's why I added a way to disable a metric with openmetrics_skipped_classes and also the Cached exporter. I hope both mechanisms will be enough (maybe cached exporter will need to be configurable to run only once per hour or even less)

@icewind1991

Copy link
Copy Markdown
Member

Some of these (counting files) are going to have a non-trivial cost, might be worth having a way to toggle individual metrics.

You are right :) That's why I added a way to disable a metric with openmetrics_skipped_classes and also the Cached exporter. I hope both mechanisms will be enough (maybe cached exporter will need to be configurable to run only once per hour or even less)

Ok, missed that when skimming over the changes 🙈

@Altahrim
Altahrimforce-pushed the feat/openmetrics branch 3 times, most recently from f494623 to 292a77aCompareJanuary 7, 2026 08:30
Expose a `/metrics` endpoint with some basic metrics
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
@Altahrim
Altahrim merged commit 62513df into masterJan 7, 2026
202 of 208 checks passed
@Altahrim
Altahrim deleted the feat/openmetrics branch January 7, 2026 09:43
@AltahrimAltahrim removed the 3. to review Waiting for reviews label Jan 7, 2026
@nextcloud-botnextcloud-bot mentioned this pull request Jan 7, 2026
@AndyScherzingerAndyScherzinger moved this from 🏗️ In progress to ☑️ Done in 📁 Files teamJan 7, 2026
namespace OCA\Comments\OpenMetrics;

use Generator;
use OC\DB\Connection;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be OCP\IDBConnection


public function __construct(
private IAppManager $appManager,
private PsrLoggerAdapter $logger,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not LoggerInterface ?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right for both, thank you. I'll do a follow-up PR :)

@rizlas

Copy link
Copy Markdown

Hi,
sorry for bother, but am I wrong or haven't any metrics regarding groups been implemented?

@Altahrim

Copy link
Copy Markdown
CollaboratorAuthor

@rizlas You are right, there isn't any for now but the exporter can be extended.
What kind of metric do you have in mind?

@susnuxsusnux added the pending documentation This pull request needs an associated documentation update label Jan 28, 2026
@susnux

Copy link
Copy Markdown
Contributor

@rizlas

Copy link
Copy Markdown

@Altahrim Thanks! I was basically thinking about the number of groups and users per group.
It would be nice to also extend https://github.com/nextcloud/groupquota (as specified here https://docs.nextcloud.com/server/latest/developer_manual//digging_deeper/openmetrics.html#implement-a-new-exporter) with: quota per group, quota used per group and free quota per group.

@Altahrim

Copy link
Copy Markdown
CollaboratorAuthor

@rizlas Number of groups and number of users per group can be added in Nextcloud, but I am afraid we don't have any straightforward way to get the metrics.
For the number of users per group, I don't know what would be the best statistic. Maybe min/max/avg size or a histogram…

All metrics related to quota must be added in groupquota app as you mentioned :)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: monitoringFeatures related to observabilityphpPull requests that update Php code

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

9 participants

@Altahrim@icewind1991@rizlas@susnux@tcitworld@CarlSchwan@come-nc@AndyScherzinger@joshtrichards