prometheus-community / prometheus-community/stackdriver_exporter
[feature request] Add Support for Exposing userLabels from GCP Resources as Prometheus Labels
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 295
- Forks
- 117
- Avg merge
- 9d 14h
- Merged PRs (30d)
- 7
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the exporter logic that maps Stackdriver resource.labels into Prometheus metric labels, focusing on the resource.labels field and metric export path mentioned in the issue. Review how command-line options are defined before deciding how the optional user-label setting should fit. Done means userLabels can be mapped to exported metrics and optionally enabled or disabled as requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, google-cloud, prometheus
- Domain
- cloud, observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100