Skip to content

Inconsistent behavoir when label already exists #162

@jacobbaungard

Description

@jacobbaungard

The way prom-label-proxy deals with labels already existing differs between the query apis (/api/v1/query, /api/v1/query_range) and the non-query apis (like: /api/v1/series, /api/v1/labels ...), which can cause a little confusion.

Given the following setup:

./prom-label-proxy \
   -label "tenant_id" \
   -label-value prom_label_proxy \
   -upstream http://localhost:32788 \
   -insecure-listen-address 127.0.0.1:8081

Query APIs
A query such as:

curl "http://localhost:8081/api/v1/query?query=\{a=\"1\",tenant_id=\"tenant-01\"\}"

Is re-written to:

{a="1",tenant_id="prom_label_proxy"}

The user provided tenant_id label is silently replaced, by prom-label-proxy.

With -error-on-replace enabled, a 400 is returned:

{"error":"label matcher value (tenant_id=\"prom_label_proxy\") conflicts with injected value (tenant_id=\"tenant-01\")","errorType":"prom-label-proxy","status":"error"}

Non-query APIs

For non-query APIs, the behavior is a bit different, instead of silently replacing the existing label, the matcher is added on. For example:

curl -g 'http://127.0.0.1:8081/api/v1/series?' --data-urlencode 'match[]={a="1", tenant_id="1"}'

Results in the following match[] arguments being sent to Prometheus:

[a="1" tenant_id="1" tenant_id=~"prom_label_proxy"]
[tenant_id=~"prom_label_proxy"]

-error-on-replace has no effect on the behavior of the non-query APIs.

What is the desired functionality here? It seems like it would be nice for the behavior to be consistent between all endpoints?

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