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

Dynamic relabelling only sets one last target_label #3472

Closed
bookwar opened this Issue Nov 14, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@bookwar
Copy link

bookwar commented Nov 14, 2017

What did you do?
Following example in #2078 I have a Nomad service which is scraped from Consul with
__meta_consul_tags = ,label-env-dev,label-project-myproject,label-team-myteam,

Then the following relabeling rules are applied:

      - source_labels: [__meta_consul_tags]
        regex: '.*,label-([[:alnum:]]+)-([^,]+),.*'
        replacement: '${2}'
        target_label: '${1}'

What did you expect to see?

Labels env=dev, project=myproject and team=myteam

What did you see instead?

Only the last label is applied: team=myteam

Environment

  • Prometheus version:
    latest image from docker hub docker.io/prom/prometheus
    version="(version=2.0.0, branch=HEAD, revision=0a74f98628a0463dddc90528220c94de5032d1a0)"
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Nov 14, 2017

That's how regular expression work. See https://www.robustperception.io/extracting-full-labels-from-consul-tags/

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

@bookwar

This comment has been minimized.

Copy link
Author

bookwar commented Nov 14, 2017

I misread the #2078 then, and expected different result from it.

Thanks for the link, it works indeed.

- source_labels: [__meta_consul_tags]
        regex: ',(?:[^,]+,){0}label-([[:alnum:]]+)-([^,]+),.*'
        replacement: '${2}'
        target_label: '${1}'
      - source_labels: [__meta_consul_tags]
        regex: ',(?:[^,]+,){1}label-([[:alnum:]]+)-([^,]+),.*'
        replacement: '${2}'
        target_label: '${1}'
      - source_labels: [__meta_consul_tags]
        regex: ',(?:[^,]+,){2}label-([[:alnum:]]+)-([^,]+),.*'
        replacement: '${2}'
        target_label: '${1}'
      - source_labels: [__meta_consul_tags]
        regex: ',(?:^,]+,){3}-(label-[[:alnum:]]+)-([^,]+),.*'
        replacement: '${2}'
        target_label: '${1}'
@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

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