Why prom-client is not showing registered metrics in the metrics endpoint?

1.7k Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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)

0
On

If you want use global Registry you should import register instead Registry...

Like: import { register } from 'prom-client'