-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selective scrape via query parameters #42
Comments
Looks like Query params are accessible as e.g. |
Currently, I'm not sure how to add Param support to the /metrics endpoint. However, I think it would be fine if we use a different endpoint, like /inspect. We could implement it similarly to health check functions, providing an inspection interface for the internal data structures of the Exporter/Server/Collector. This way, we could retrieve a subset of the metrics. If you're interested in adding any implementation, I'd be more than happy to collaborate. |
Thanks. I aim to do just that. |
Looks like managing multiple registries is the preferred way to handle grouping: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#Registry . It can also be used for things like parallel scrape from multiple goroutines, if required. To select the group to return, a custom The downside of that is that the registries should probably be pre-created. So filtering by generic tags wouldn't work so well. I'd suggest either adding Another option is to use Edit: I see that I'll look at a wrapper http handler instead. The Prometheus API is not great - it doesn't pass |
Raised prometheus/client_golang#1538 with prom client. If prom propagated As it is, it looks like a custom
It's so ugly that I feel like I must be missing some obvious way this can be done correctly. There doesn't seem to be any sane, concurrency-safe way to pass request context through But here's the working-if-ugly PoC branch https://github.com/ringerc/pg_exporter_patches/tree/pr-selective-scrape |
I haven't forgotten this, and will try to clean up and upstream my patch when I get the chance. Just under the pump for some internal work. |
;) I'll make an alpha release for v0.7.0-a1; once merged and tested, |
Thanks. As it stands my working branch is way too dirty to merge. I'll try to get back to cleaning it up and finishing it off. |
I'm looking at adopting
pg_exporter
as a potential replacement for the CloudNative-PG built-in scraper I currently use.CNPG doesn't support this either, but I was considering implementing it for CNPG and wonder if I should do so for
pg_exporter
instead.Do you have any advice on how I might go about adding support for scraping selected subsets of metrics, specified by tag-set, with query parameters?
I want to scrape different subsets at different frequencies without having to deploy multiple instances of the scraper. This can't be done with command-line or env-var level tags.
E.g. I want to scrape
/metrics?tags=expensive_metrics,wide_cardinality_metrics
every 5min, and/metrics?cheap_narrow_metrics
every 30s.The scraper's caching feature makes this a less pressing need than it is in other scrapers, but since it already has tagging I'm wondering if it might be fairly easy to add. I can't immediately see how to access the query params from/within
promhttp
in order to apply them selectively though. Do you know if this might be possible, and have any ideas about how? If so, I can see if I can cook up a patch if my initial PoC with this scraper works out.(See related #41, #43 )
The text was updated successfully, but these errors were encountered: