can't get metrics from federate prometheus with consul

53 views
Skip to first unread message

顾鹏飞

unread,
Nov 2, 2020, 7:27:20 PM11/2/20
to Prometheus Users

**What did you do?**
service discovery used consul

metrics_path: '/federate' in scrape_configs

**Environment**

* System information:

centos 7

* Prometheus version:

2.19.3

* Prometheus configuration file:

for example
```
scrape_configs:
      #The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
      - job_name: 'consul-m'
        honor_labels: true
        metrics_path: '/federate'
        consul_sd_configs:
        - server: '172.32.155.101:8500'
          services:
            - prometheus1
        relabel_configs:
        - regex: __meta_consul_service_metadata_(.+)
          action: labelmap

      - job_name: 'consul-f'
        honor_labels: true
        scheme: https
        tls_config:
          ca_file: /conf/pem/ca.pem
          cert_file: /conf/pem/client.pem
          key_file: /conf/pem/client-key.pem
          insecure_skip_verify: true
        metrics_path: '/federate'
        consul_sd_configs:
        - server: '172.32.155.101:8500'
          services:
            - prometheus2
        relabel_configs:
        - regex: __meta_consul_service_metadata_(.+)
          action: labelmap
```


* Logs:
```
no error logs

discovery services successfully and target state is up , but it can't get metrics ,it shows no data

curl get request '/api/v1/targets/metadata' return {"status":"success","data":[]}
```

Brian Candler

unread,
Nov 3, 2020, 3:27:56 AM11/3/20
to Prometheus Users
You can't just scrape the naked /federate endpoint, you need to give it a match[] query parameter (set using "params" in your scrape job).

I suggest you get it working with curl first, and then configure your scrape job accordingly:

=> empty response

=> response includes the given metrics

The documentation, with example configuration, is here: https://prometheus.io/docs/prometheus/latest/federation/#configuring-federation
Reply all
Reply to author
Forward
0 new messages