Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metric_relabel_configs does not drop __-prefixed labels as documented #5092

Closed
hoffie opened this Issue Jan 13, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@hoffie
Copy link

hoffie commented Jan 13, 2019

Bug Report

What did you do?
When using a two-step relabeling in metric_relabel_configs, it may be necessary to use temporary labels for storing state. The docs suggest using the __-prefix (or even __tmp prefix) for such temporary labels and states that such labels will be removed after completing relabeling:

Labels starting with __ will be removed from the label set after relabeling is completed.

This does not seem to be the case.

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
    metric_relabel_configs:
      - source_labels: [__name__] 
        regex: 'process_open_fds'
        action: replace
        target_label: __tmp_foo
        replacement: 1

What did you expect to see?
The relabeled metric should not contain a __tmp_foo label.

What did you see instead? Under which circumstances?
The relabeled metric still contains the __tmp_foo label:

$ curl -s 'http://localhost:9090/api/v1/query?query=process_open_fds' | python -m json.tool
{
    "status": "success",
    "data": {
        "resultType": "vector",
        "result": [
            {
                "metric": {
                    "__name__": "process_open_fds",
                    "__tmp_foo": "1",
                    "instance": "localhost:9090",
                    "job": "prometheus"
                },
                "value": [
                    1547384438.198,
                    "15"
                ]
            }
        ]
    }
}

Environment

  • System information: Linux 4.19.8-arch1-1-ARCH x86_64
  • Prometheus version:
  build user:       root@bf5760470f13
  build date:       20181217-15:14:46
  go version:       go1.11.3

This behavior can be worked around by another metric relabeling step, but I think this is an actual bug in Prometheus (or at least a documentation bug, if the cited sentence is supposed to be restricted to relabel_configs).

@hoffie hoffie changed the title metric_relabel_configs does not drop __-prefixed metrics as documented metric_relabel_configs does not drop __-prefixed labels as documented Jan 13, 2019

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jan 13, 2019

That logic only applies to target relabelling, the latest docs clarify this.

@hoffie

This comment has been minimized.

Copy link
Author

hoffie commented Jan 20, 2019

That logic only applies to target relabelling, the latest docs clarify this.

I'm afraid I don't fully understand -- I did not find a clarification in the live docs or the Git repo.
From @brian-brazil's comment I assumed that a fix is already in the pipeline somewhere. From @simonpasquier's label change I would assume that someone should send a PR...?

Can someone clarify? I'm happy to send a pull request.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jan 20, 2019

@simonpasquier

This comment has been minimized.

Copy link
Member

simonpasquier commented Feb 1, 2019

The documentation website will get the update once prometheus/docs#1273 is merged. @hoffie hope you don't mind if I close this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.