I have just registered some metrics in a NestJS application, through a typescript decorator. I use the prom-client
package, but although I can log the metrics registered, the endpoint is not exposing those, and the Prometheus docker instance that I use to show all metrics, are not showing those neither.
how can I do to view registered metrics in /metrics endpoint and the Prometheus dashboard?
I solved passing to the custom metric in the constructor options the registry that will be used as follow:
new Counter({ name, help, registers: [registerOn] })
where registerOn
is a reference of the register instance (from prom-client
) used in the main module (because the metrics registered in different modules are registered in different registry instances)