Prometheus target showing down

1.5k Views Asked by At

Please note: my prometheus is running using ubuntu terminal and my springboot application is running on windows. Seems like my ubuntu is not able to connect with the localhost of windows.

I have created springboot metrics using "actuator" and my metrics are being exposed at "http/localhost:8080/actuator/prometheus".

My application.yml configuration in my springboot application looks like this:

management:
  endpoints:
    web:
      exposure:
        include: prometheus


The configuration file of prometheus i.e. prometheus.yml is as below:
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from 
this config.
  - job_name: "services"
    static_configs:
      - targets: ["localhost:8080"]
    metrics_path: '/actuator/prometheus'

Despite this configuration, i see "target" as down in prometheus interface. It says

Get "http://localhost:8080/actuator/prometheus": dial tcp 127.0.0.1:8080: connect: connection refused

Why is prometheus not able to pick the metrics at localhost?

2

There are 2 best solutions below

0
On

I had a similar problem. In this case, my application used Basic Auth to access any link. So, I needed to add these lines to my configuration file :

basic_auth:
      username: "username" # username with permission on the database
      password: "password" # password compatible with username

All credit to Lucas Ribeiro Barzotto who helped by comments on devdojo video

0
On

First try this;

The configuration file of prometheus i.e. prometheus.yml is as below:

scrape_configs:

The job name is added as a label job=<job_name> to any timeseries scraped from this config.

- job_name: "services"
    static_configs:
      - targets: ["host.docker.internal:8080"]
    metrics_path: '/actuator/prometheus'

When you try this if you get this error again

'[Prometheus] Get "http://host.docker.internal:8080/metrics": dial tcp: lookup host.docker.internal on' error 

Please enter ip directly, not localhost, in the destination address xxx.xxx.xxx.xxx