How can we define custom Prometheus metrics inside Krakend plugins and expose them alongside Krakend’s built-in metrics on the /metrics endpoint?

31 views
Skip to first unread message

Satish Mhetre

unread,
Apr 27, 2025, 8:11:02 AMApr 27
to KrakenD Community

We are developing custom plugins for Krakend and would like these plugins to define their own Prometheus metrics (such as counters, gauges, histograms, etc.). Our goal is to have these custom metrics automatically collected and made available under the existing /metrics endpoint, along with Krakend's default internal metrics.

We would like to understand:

  • How to properly register plugin-defined metrics so they are picked up by the Prometheus handler.

  • Whether Krakend allows sharing its Prometheus registry or if a custom setup is needed.

  • Best practices for avoiding metric name conflicts between Krakend core metrics and plugin metrics.

Any guidance or examples on how to achieve this cleanly within the Krakend plugin system would be appreciated!

Message has been deleted

Satish Mhetre

unread,
May 6, 2025, 8:54:37 AMMay 6
to KrakenD Community, Satish Mhetre
Was able to access the metrics meter inside plugin using this code snippet

otelCfg := otelstate.GlobalConfig()
otelState := otelCfg.OTEL()
meter := otelState.Meter()

As otelstate is singleton, we will have same instance of it in plugin.
Reply all
Reply to author
Forward
0 new messages