Skip to content

Batch modification of promql queries to prevent grafana's automatic escaping of query parameters #272

@paomian

Description

@paomian

When using PromQL to query GreptimeDB, if the query contains a variable and the variable has multiple values, it is now necessary to use ${datanode:pipe}.

For example:

sum(process_resident_memory_bytes{instance=~"${datanode:pipe}"}) by (instance, pod)

After being filled by Grafana, it becomes:

sum(process_resident_memory_bytes{instance=~"172.16.214.189:4000|172.16.214.190:4000|172.16.214.193:4000"}) by (instance, pod)

Previously, using ${datanode} would separate the values with |, but it would escape the values. After version 0.14, GreptimeDB no longer supports escaped query conditions, so this approach fails.

For example:

sum(process_resident_memory_bytes{instance=~"${datanode}"}) by (instance, pod)

After being filled by Grafana, it becomes:

sum(process_resident_memory_bytes{instance=~"(172\\.16\\.214\\.189:4000|172\\.16\\.214\\.190:4000|172\\.16\\.214\\.193:4000)"}) by (instance, pod)

Initially, it was suggested to use ${datanode:raw}, but this separates the values with ,. Therefore, if the variable has multiple values, using raw will also fail.

Reference:

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