prometheus-community / stackdriver_exporter

Google Stackdriver Prometheus exporter
Apache License 2.0
263 stars 99 forks source link

feat: support more specific prefixes in ?collect parameter #387

Open antoinedeschenes opened 1 week ago

antoinedeschenes commented 1 week ago

This changes the ?collect parameter filter to allow more specific prefixes than those setup in the metrics-prefixes.

Example use cases:

  1. I have the redis.googleapis.com/stats/memory/usage_ratio prefix set in the ?collect config of dozens of projects.

Now, I'd like to enable the redis.googleapis.com/stats/memory/usage metric in the stackdriver_exporter metric prefixes, but since it conflicts with the more-specific redis.googleapis.com/stats/memory/usage_ratio metric name, the exporter will stop accepting the ?collect param I've set in other configurations.

  1. I want to whitelist all redis.googleapis.com metrics, but only collect 1 or 2 metrics with ?collect. Currently, the prefixes have to be exact matches so this is not possible without the proposed change.

To test:

$ go run . --google.project-id=<gcp-project-name> --monitoring.metrics-prefixes=redis.googleapis.com/stats/
$ curl http://localhost:9255/metrics?collect=redis.googleapis.com/stats/memory/usage/ | grep stackdriver_redis

Other question: is there a technical reason that would prevent from having a flag disabling prefix filtering in ?collect?

antoinedeschenes commented 1 week ago

cc: @SuperQ @kgeckhart

antoinedeschenes commented 1 week ago

Looks like that feature was already implemented along another change and then reverted through PR #316

though the reason for the revert seems to be that the main handler was removed, which caused a regression to aggregate-deltas #315

antoinedeschenes commented 4 days ago

The configuration could be a bit confusing if you have to provide metric prefixes that are completely ignored when calling collect.

Oh, by that I mean that ?collect could allow to specify metric prefixes that aren't specified in the exporter command-line arguments