client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

feature: pull web.disable-exporter-metrics functionality into this package

Open pdf opened this issue 3 years ago • 8 comments

The node_exporter implements a command-line flag web.disable-exporter-metrics that disables publishing the exporter's process stats. Pulling that functionality into this package with some sort of flag helper similar to promlog would allow all Go exporters to benefit from this behaviour without having to re-implement it.

pdf avatar Jun 21 '21 23:06 pdf

Great idea! I was just on my way to open a similar issue with a request to make it easy to disable the goCollector metrics as they seem only helpful during development but not in production for most exporters.

Currently I do this by adding this line to the code of some exporters right after the MustRegister call (not knowing if it is a bad idea): prometheus.Unregister(prometheus.NewGoCollector()

leahoswald avatar Jun 23 '21 16:06 leahoswald

I have also done this by replacing the default registerer/gatherer in my codebases. r := prometheus.NewRegistry() prometheus.DefaultRegisterer = r prometheus.DefaultGatherer = r

It'd be nice to not have to do this dance though, or filter out the go/process metrics in other ways.

justinbeal avatar Jun 25 '21 17:06 justinbeal

I think it would be useful to have a configuration struct/method for the default Go/Process collector.

SuperQ avatar Sep 21 '21 08:09 SuperQ

The clearest way to not use the collectors already pre-registered with the default registry is indeed to create your own registry (which is anyway recommended for any non-trivial Go program to avoid global state).

The exporter metrics are somewhat different as they could be more than just those. Perhaps having that flag in https://github.com/prometheus/exporter-toolkit would make sense?

beorn7 avatar Sep 21 '21 15:09 beorn7

Hello 👋 Looks like there was no activity on this issue for the last 3 months. Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗 If there will be no activity in the next 4 weeks, this issue will be closed (we can always reopen an issue if we need!).

stale[bot] avatar Mar 25 '22 07:03 stale[bot]

Still desirable for consistency.

pdf avatar Mar 25 '22 08:03 pdf

I spun up a new exporter and noticed that the default registry now has 124 metrics. It would be nice to have a "light" mode that doesn't include a lot of the excessive details for simple exporters.

For example, I don't really need these two detailed histograms most of the time. But it would be nice to have a flag to enable them.

go_gc_heap_allocs_by_size_bytes_total_bucket{le="8.999999999999998"} 2.488515e+06
go_gc_heap_allocs_by_size_bytes_total_bucket{le="24.999999999999996"} 2.5126955e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="64.99999999999999"} 4.0245214e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="144.99999999999997"} 4.8441256e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="320.99999999999994"} 5.0162094e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="704.9999999999999"} 5.1115383e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="1536.9999999999998"} 5.1425539e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="3200.9999999999995"} 5.1477494e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="6528.999999999999"} 5.165292e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="13568.999999999998"} 5.1659736e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="27264.999999999996"} 5.1713698e+07
go_gc_heap_allocs_by_size_bytes_total_bucket{le="+Inf"} 5.1740452e+07
go_gc_heap_allocs_by_size_bytes_total_sum 1.0629995408e+10
go_gc_heap_allocs_by_size_bytes_total_count 5.1740452e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="8.999999999999998"} 2.484419e+06
go_gc_heap_frees_by_size_bytes_total_bucket{le="24.999999999999996"} 2.5115579e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="64.99999999999999"} 4.022865e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="144.99999999999997"} 4.8421552e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="320.99999999999994"} 5.0141065e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="704.9999999999999"} 5.1093727e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="1536.9999999999998"} 5.1403774e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="3200.9999999999995"} 5.1455678e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="6528.999999999999"} 5.163104e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="13568.999999999998"} 5.1637842e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="27264.999999999996"} 5.1691798e+07
go_gc_heap_frees_by_size_bytes_total_bucket{le="+Inf"} 5.1718539e+07
go_gc_heap_frees_by_size_bytes_total_sum 1.062535436e+10
go_gc_heap_frees_by_size_bytes_total_count 5.1718539e+07

SuperQ avatar Mar 25 '22 08:03 SuperQ

So, from what I understand, two new flags are needed:

  1. as @pdf suggests, one to disable all default metrics, for consistency with exporter-toolkit.
  2. as @SuperQ suggests, one to selectively turn on some metrics.

Please let me know if I missed something, trying to understand. Thanks!

metonymic-smokey avatar Apr 30 '22 03:04 metonymic-smokey