Skip to content

Remote read adding external labels might lead to unsorted response #12605

@GiedriusS

Description

@GiedriusS

What did you do?

/api/v1/read is supposed to always give a sorted series set as a response. Consider the following:

External labels are region: foo.

Series without any external labels:


aaa{instance="bbb", job="etcd-prometheus-exporter", service="etcd-prometheus-exporter", toposphere="test1"} 1
aaa{instance="bbb", job="etcd-prometheus-exporter", region="bar", service="etcd-prometheus-exporter", toposphere="test1"} 0
aaa{instance="bbb", job="etcd-prometheus-exporter", region="bar", service="etcd-prometheus-exporter", toposphere="test2"} 0
aaa{instance="bbb", job="etcd-prometheus-exporter", region="foo", service="etcd-prometheus-exporter", toposphere="test1"} 1
aaa{instance="bbb", job="etcd-prometheus-exporter", region="foo", service="etcd-prometheus-exporter", toposphere="test2"} 1

lbls = MergeLabels(labelsToLabelsProto(series.Labels(), lbls), sortedExternalLabels)
here is where Prometheus adds region: foo if it does not exist while iterating.

What did you expect to see?

I expected to see an error? that the response cannot contain the same label set. Not sure, though.

What did you see instead? Under which circumstances?

The result is the following:


aaa{instance="bbb", job="etcd-prometheus-exporter", region="foo", service="etcd-prometheus-exporter", toposphere="test1"} 1
aaa{instance="bbb", job="etcd-prometheus-exporter", region="bar", service="etcd-prometheus-exporter", toposphere="test1"} 0
aaa{instance="bbb", job="etcd-prometheus-exporter", region="bar", service="etcd-prometheus-exporter", toposphere="test2"} 0
aaa{instance="bbb", job="etcd-prometheus-exporter", region="foo", service="etcd-prometheus-exporter", toposphere="test1"} 1
aaa{instance="bbb", job="etcd-prometheus-exporter", region="foo", service="etcd-prometheus-exporter", toposphere="test2"} 1

System information

No response

Prometheus version

No response

Prometheus configuration file

No response

Alertmanager version

No response

Alertmanager configuration file

No response

Logs

No response

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