Skip to content

Colon symbol gets removed from the filter query #4186

@yusorokin

Description

@yusorokin

Component(s)

prometheus.exporter.gcp

What's wrong?

The : (colon) symbol gets removed from the filter query in extra_filters block and there is no way to quote or escape it.

Steps to reproduce

Use this configuration:

logging {
  level  = "debug"
  format = "logfmt"
}

prometheus.exporter.gcp "storage" {
  project_ids = [
    "your_project_id",
  ]
  metrics_prefixes = [
    "cloudsql.googleapis.com/database/cpu",
  ]
  extra_filters = [
    "cloudsql.googleapis.com/database/cpu:resource.labels.database_id=\"your_project_id:your_database_name\"",
  ]
}

and see the following logs:

ts=2025-08-13T10:40:09.037420454Z
level=debug
msg="retrieving Google Stackdriver Monitoring metrics with filter"
component_path=/
component_id=prometheus.exporter.gcp.storage
project_id=your_project_id
filter="metric.type=\"cloudsql.googleapis.com/database/cpu/usage_time\"
  AND (resource.labels.database_id=\"your_project_idyour_database_name\")"

So, it deletes the : (colon) symbol from the initial filter query your_project_id:your_database_name turning it into your_project_idyour_database_name.

It seems there was a similar problem on the Stackdriver Exporter side, and they resolved it with this PR.

System information

No response

Software version

Grafana Alloy v1.10.0

Configuration

logging {
  level  = "debug"
  format = "logfmt"
}

prometheus.exporter.gcp "storage" {
  project_ids = [
    "your_project_id",
  ]
  metrics_prefixes = [
    "cloudsql.googleapis.com/database/cpu",
  ]
  extra_filters = [
    "cloudsql.googleapis.com/database/cpu:resource.labels.database_id=\"your_project_id:your_database_name\"",
  ]
}

Logs

ts=2025-08-13T10:40:09.037420454Z
level=debug
msg="retrieving Google Stackdriver Monitoring metrics with filter"
component_path=/
component_id=prometheus.exporter.gcp.storage
project_id=your_project_id
filter="metric.type=\"cloudsql.googleapis.com/database/cpu/usage_time\"
  AND (resource.labels.database_id=\"your_project_idyour_database_name\")"

Tip

React with 👍 if this issue is important to you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions