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
userLabels
from theresource.labels
field for each monitored resource. - Map the
userLabels
to Prometheus metric labels during metric export. - Allow users to optionally enable or disable
userLabels
in the exported metrics via a command-line flag (e.g., --include-user-labels
).
More info about GCP resource labeling can be found here