Skip to content

[feature request] Add Support for Exposing userLabels from GCP Resources as Prometheus Labels #390

Open
@elenaknofs

Description

@elenaknofs

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:
  1. Dynamically filter metrics based on userLabels in Prometheus queries.
  2. Set up targeted alerts for resources with specific labels (e.g., suppress alerts for resources with monitoring=false).
  3. Enhance observability by grouping metrics using custom tags.

Implementation Details

  • Extend the exporter’s logic to fetch userLabels from the resource.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions