-
Notifications
You must be signed in to change notification settings - Fork 111
Description
We would like to request support for exposing userLabels from Google Cloud resources (e.g., Compute Engine, Cloud SQL) as Prometheus metric labels in the Google Stackdriver Prometheus Exporter.
Currently, while the exporter successfully maps Stackdriver metrics and their associated resource labels to Prometheus, custom userLabels defined on resources in Google Cloud are not included. These labels are essential for enabling dynamic filtering, categorization, and fine-grained alerting in Prometheus.
Adding support for userLabels would improve the usability of the exporter by aligning it with real-world use cases where custom metadata is used to manage metrics across complex environments.
Use Case
In environments with a large number of Google Cloud resources, userLabels are commonly used to define metadata such as:
- Maintenance states (
monitoring=true/false) - Environment information (
env=prod,env=stage) - Resource ownership (
team=devops,team=dba)
Including userLabels in the exported metrics would allow users to:
- Dynamically filter metrics based on userLabels in Prometheus queries.
- Set up targeted alerts for resources with specific labels (e.g., suppress alerts for resources with
monitoring=false). - Enhance observability by grouping metrics using custom tags.
Implementation Details
- Extend the exporter’s logic to fetch
userLabelsfrom theresource.labelsfield for each monitored resource. - Map the
userLabelsto Prometheus metric labels during metric export. - Allow users to optionally enable or disable
userLabelsin the exported metrics via a command-line flag (e.g., --include-user-labels).
More info about GCP resource labeling can be found here