how to use prometheus to scrape consul(1.1) metrics?

1,057 views
Skip to first unread message

ofs...@gmail.com

unread,
May 24, 2018, 3:01:34 AM5/24/18
to Prometheus Users
Hi guys, I know consul 1.1 has supported prometheus metrics using /v1/agent/metrics?format=prometheus , but I can not relabel to this format, there's some error message like this "err="instance 0 in group telemetry: \"xx.xx.xx.xx/v1/agent/metrics?format=prometheus:80\" is not a valid hostname"", my configuration like below:

  - job_name: 'consul_metrics'

    consul_sd_configs:

    - server: 'x.x.x.x:8500'

      services:

        - 'telemetry'

    relabel_configs:

    - source_labels: ['__meta_consul_address']

      target_label:  __address__

      replacement:   '${1}/v1/agent/metrics?format=prometheus'


anyone can help? thanks in advance!                                                                                                                                                                                                                                                

Simon Pasquier

unread,
May 24, 2018, 3:17:02 AM5/24/18
to ofs...@gmail.com, Prometheus Users
You just have to set the metrics_path parameter to "/v1/agent/metrics?format=prometheus" at the job configuration level. No need for relabeling here.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/1b28ae68-c52d-4d18-8987-3acf4ab155e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ofs...@gmail.com

unread,
May 24, 2018, 3:32:43 AM5/24/18
to Prometheus Users
Hi Simon, thanks for your quick reply, after making some modifications to add params, it works.

  - job_name: 'consul_metrics'

    metrics_path: '/v1/agent/metrics'

    params:

      format : ['prometheus']

    consul_sd_configs:

    - server: 'xx.xx.xx.xx:8500'

      services:

        - 'telemetry'


在 2018年5月24日星期四 UTC+10下午5:17:02,Simon Pasquier写道:
You just have to set the metrics_path parameter to "/v1/agent/metrics?format=prometheus" at the job configuration level. No need for relabeling here.
On Thu, May 24, 2018 at 9:01 AM, <ofs...@gmail.com> wrote:
Hi guys, I know consul 1.1 has supported prometheus metrics using /v1/agent/metrics?format=prometheus , but I can not relabel to this format, there's some error message like this "err="instance 0 in group telemetry: \"xx.xx.xx.xx/v1/agent/metrics?format=prometheus:80\" is not a valid hostname"", my configuration like below:

  - job_name: 'consul_metrics'

    consul_sd_configs:

    - server: 'x.x.x.x:8500'

      services:

        - 'telemetry'

    relabel_configs:

    - source_labels: ['__meta_consul_address']

      target_label:  __address__

      replacement:   '${1}/v1/agent/metrics?format=prometheus'


anyone can help? thanks in advance!                                                                                                                                                                                                                                                

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages