Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus: invalid hostname with https scheme

Tags:

prometheus

prometheus is telling me that:

"https://some-domain.com/backoffice" is not a valid hostname"

My config file is:

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
            - targets: ['192.168.99.102:8085', '192.168.99.102:8083', '192.168.99.102:8084', 'https://<domain>/backoffice']

Any ideas?

like image 411
Jordi Avatar asked Dec 11 '22 01:12

Jordi


1 Answers

As Gaurav said in his answer, we can only use the host type (<domain>) in the targets array. In order to incorporate the https scheme and the path /backoffice, you need to use scheme and metric_path properties respectively in the configuration (scheme defaults to http and metric_path to /metrics if not mentioned explicitly).

I see that you have already added the metric_path:'/actuator/prometheus' which is shared among other targets. Therefore, you might need to create different scrape job for the one having a different metric_path and scheme as shown here:

  - job_name: 'spring_micrometer_2'
    scrape_interval: 5s
    metrics_path: "/backoffice/actuator/prometheus"
    scheme: "https"
    static_configs:
      - targets:<domain>

If you want to have same job name "spring_micrometer" on all the targets, you can make use of relabel_configs as shown below on the "spring_micrometer_2" job:

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
            - targets: ['192.168.99.102:8085', '192.168.99.102:8083', '192.168.99.102:8084']
  - job_name: 'spring_micrometer_2'
    scrape_interval: 5s
    metrics_path: "/backoffice/actuator/prometheus"
    scheme: "https"
    static_configs:
      - targets:<domain>
    relabel_configs:
      - source_labels: [job]
        target_label:  job
        replacement:   `spring_micrometer`
like image 76
Chowta Avatar answered Feb 15 '23 19:02

Chowta