jochen-schweizer / express-prom-bundle

express middleware with standard prometheus metrics in one bundle
MIT License
303 stars 67 forks source link

Exclude /metrics route #68

Closed piks2252 closed 3 years ago

piks2252 commented 3 years ago

Hello, First of all thank you so much for this library, I appreciate you hard word, Now i don't want to display /metrics request in my grafana dashboard, Is there any way to exclude /metrics route I tried app.use("/((?!metrics))*", promBundle({includePath: true}));, but It blocks the /metrics and returns no route found which was the only access point (target) for my Prometheus server to access metrics data. I just want to exclude "/metrics" path in my collection which is polluting my app's APIs. Thanks

disjunction commented 3 years ago

Hi. The /metrics path is excluded automatically, you don't need to do anything. Have you tested it?

gmeher commented 3 years ago

HI @disjunction, Thanks for your quick reply. @piks2252 and me works on same team. please find the attachment, "/metrics" is retained in my data metrics and same is being scraped by Prometheus server, which is polluting our business/app APIs. Screen Shot 05-11-2020 at 14 26 Screen Shot 05-11-2020 at 14 26 - 2

disjunction commented 3 years ago

I'm afraid it's due to the way you use the module or a potential conflict with multiple prom clients. Could you provide the how the prom-client and express-prom-bundle are defined in your project.json and also how you call promBundle() in your app?

disjunction commented 3 years ago

... and if you do anything directly with prom-client, please mention it too

gmeher commented 3 years ago

Hi @disjunction ,Thanks. we were running swagger-stats as well in our Application server. after removing, it worked fine. It would be better If you can mention in the readme, will be helpful for others.

piks2252 commented 3 years ago

Thanks @disjunction for your support.