A.khalifa
A.khalifa

Reputation: 2496

Endpoint IP not changed in Prometheus target specified in prometheus.yml

I want to use Prometheus with my spring boot project, I'm new in Prometheus that way i do not know why I get error describe in picture

enter image description here

My prometheus.yml like below

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.43.71:8080/app']

I run prometheus by this command docker run -d -p 9090:9090 -v <path-to-prometheus.yml>:/etc/prometheus/prometheus.yml prom/prometheus

I notice my ip not show in Prometheus targets page :

enter image description here

Normally Endpoint IP must be like 192.168.43.71:8080/app/actuator/prometheus but I get http://localhost:9090/metrics and when I click in it, i get error describe in picture 1

What I do wrong ?!, anyone can help me to resolve this issue and thanks.

Upvotes: 1

Views: 1393

Answers (1)

trallnag
trallnag

Reputation: 2376

You cannot do this - targets: ['192.168.43.71:8080/app']. Try the following:

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/app/actuator/prometheus/metrics'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.43.71:8080']

Why does your config not work? Take a look at the config docs here: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#host

targets is a collection of host and host must be a "valid string consisting of a hostname or IP followed by an optional port number".

Upvotes: 1

Related Questions