nginxinc/nginx-prometheus-exporter

Filtering metrics

fxposter opened this issue · 4 comments

Is your feature request related to a problem? Please describe.
What do you think about the ability to not show all metrics. There are cases when exporter has a lot of metrics (for example, there are a lot of upstream servers) and the user doesn't need all of them.

Describe the solution you'd like
I propose having the ability to apply 2 types of filters:

  1. show only metrics that match user-specified regex
  2. show only metrics that have non-zero values (this is very useful for metrics like nginxplus_upstream_server_fails or nginxplus_upstream_server_unavail, which are usually zeros all the time)

Describe alternatives you've considered
it is usually possible to reject some metrics on scraper side, but it's less efficient and usually "what metrics are exposed" and "what metrics are gathered" are controlled by different parties, so I just propose to add this ability to the project.

I'm happy to do the PR if the idea is accepted.

Hi @fxposter,

This seems like an interesting feature. How would you enable the filters?

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days.

Since the proliferation of metrics is primarily caused by NGINX Plus it seems that the most straightforward way to introduce a filter would be by excluding / including based on the N+ API paths as the basis for metrics groups.
Ignoring the N+ API version but the group after.
Focusing on the GETs here: https://demo.nginx.com/swagger-ui/

Things like zone names are highly configuration dependent and could be relatively simple to disrupt. But I can see how something like that could relate to the regex suggestion.