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

consul_sd_configs __meta_consul_tags relabaling #499

Open
suikast42 opened this issue Jan 26, 2023 · 2 comments
Open

consul_sd_configs __meta_consul_tags relabaling #499

suikast42 opened this issue Jan 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@suikast42
Copy link

I am sracping consul metrics over consul_sd_configs
with the cinfig shown below:

       - job_name: "integrations/consul_sd_minio"
          metrics_path: "/minio/v2/metrics/cluster"
          consul_sd_configs:
            - server: "consul.service.consul:8501"
              tags: ["prometheus_minio"]
              tls_config:
                insecure_skip_verify: true
                ca_file: "/certs/ca/ca.crt"
                cert_file: "/certs/consul/consul.pem"
                key_file: "/certs/consul/consul-key.pem"
              datacenter: "{{data_center}}"
              scheme: https
          relabel_configs:
            - source_labels: [__meta_consul_node]
              target_label: instance
            - source_labels: [__meta_consul_service]
              target_label: service
            - source_labels: [__meta_consul_tags]
              separator:     ','
              regex:         '.*,prometheus:server=([^,]+),.*'
              target_label:  'server'
              replacement:   '$${1}'
            - source_labels: [__meta_consul_tags]
              separator:     ','
              regex:         '.*,prometheus:version=([^,]+),.*'
              target_label:  'version'
              replacement:   '$${1}'

For mimimize the relabeling config I thought I can relable all consul tags which starts wih prometheus:
with the config:

            - source_labels: [__meta_consul_tags]
              separator:     ','
              regex:         'prometheus:([^=]+)=([^,]+)'
              target_label:  '$${1}'
              replacement:   '$${2}'

But it seems that grafana agent can relabel on match at time. Right? Or did I miss something?

@rfratto
Copy link
Member

rfratto commented Feb 4, 2023

Yes, it looks like because of the way __meta_consul_tags is generated by service discovery, you can only relabel one at a time. There was some information about this here: https://www.robustperception.io/extracting-full-labels-from-consul-tags/

@suikast42
Copy link
Author

suikast42 commented Feb 6, 2023

Yes, it looks like because of the way __meta_consul_tags is generated by service discovery, you can only relabel one at a time. There was some information about this here: https://www.robustperception.io/extracting-full-labels-from-consul-tags/

Isn't this approach outdated? 😜

@rfratto rfratto added the enhancement New feature or request label Apr 9, 2024
@rfratto rfratto transferred this issue from grafana/agent Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

No branches or pull requests

2 participants