Custom metrics from plugins

47 views
Skip to first unread message

Patrick Karlsson

unread,
Jan 22, 2024, 9:08:33 AMJan 22
to KrakenD Community
Hi! 

Is it possible to add custom metrics to prometheus exporter? 

And how would we add metrics in custom plugins?

Best regards,
Patrick

Daniel Ortiz

unread,
Jan 22, 2024, 9:46:30 AMJan 22
to KrakenD Community, patrick....@fortnox.se
Hi Patrick,

The prometheus metrics provided by KrakenD are Opencensus (Opentelemetry soon) metrics.
If you want custom application metrics you need to code that and expose the prometheus port in the plugin.

Best regards,

Patrick Karlsson

unread,
Jan 22, 2024, 9:59:24 AMJan 22
to KrakenD Community, Daniel Ortiz, patrick....@fortnox.se
Hi Daniel,
Thanks for the answer! 

In your code, we see that you create an isolated instance of the PrometheusRegistry (no using the default registry). This way no plugin can register their metrics and automatically get them out through your Prometheus exporter. Would you consider using the default registry in Prometheus to allow plugins to register their metrics there and have them exported through your metrics endpoint or allow for plugins in some other way to attach metrics to your registry?

Best regards,
Patrick

Daniel Ortiz

unread,
Jan 23, 2024, 6:07:18 AMJan 23
to KrakenD Community, patrick....@fortnox.se, Daniel Ortiz
Hi Patrick,

Unfortunately, there are no plans to use the DefaultRegistry so it's shared with other components. The opencensus Prometheus exporter should remain isolated. Creating a new registry and sharing it in your plugins should be no problem.

Best regards,
Daniel

Patrick Karlsson

unread,
Apr 26, 2024, 10:41:27 AMApr 26
to KrakenD Community, Daniel Ortiz, patrick....@fortnox.se
Bumping this one since otel updates and the context being part of the plugin. 

Regarding the original question with custom metrics, this is not possible now with regards to the OTEL changes and the possibilities with the context now available in plugins?


Best regards

Patrick Karlsson

unread,
May 6, 2024, 9:49:32 AMMay 6
to KrakenD Community, Patrick Karlsson, Daniel Ortiz
Bumping this one once more:
https://github.com/krakend/krakend-otel/pull/22

My colleague just created this PR today. I think this one has a lot of potential for adding custom labels to existing metrics, both via custom plugins and the existing plugins. For instance, if you'd like to add a claim from a JWT as a label from the auth-validator plugin. 

Please take a look, it would bring great value to us

Best regards,
Patrick

Albert Lombarte

unread,
May 7, 2024, 5:21:40 AMMay 7
to KrakenD Community, patrick....@fortnox.se, Daniel Ortiz
Hi Patrick,

We will review the PR whenever we can, there are a lot of feature requests across all repositories.

Thank you for your patience.

El dia dilluns, 6 de maig del 2024 a les 15:49:32 UTC+2, patrick....@fortnox.se va escriure:
Reply all
Reply to author
Forward
0 new messages