Blackbox exporter not recognizing localhost/refused to connect

1,373 views
Skip to first unread message

Sean Coh

unread,
Jan 10, 2023, 3:30:08 AM1/10/23
to Prometheus Users
Hi,

I'm trying to test blackbox exporter with https prob. I'm fairly new to prometheus and grafana so I have been going over resources here. https://prometheus.io/docs/guides/multi-target-exporter/ 

Does localhost need to be changed to a specific host name? Keep getting site can't be reached.

Code from grafana_agent.yml:

scrape_configs:
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [https_2xx]
static_configs:
- targets:
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9115


Logs error: component="scrape manager" scrape_pool=blackbox target="http://localhost:9115/probe?module=https_2xx&target=https%3A%2F%2Fwww.google.com%2F" msg="Scrape failed" err="Get \"http://localhost:9115/probe?module=https_2xx&target=https%3A%2F%2Fwww.google.com%2F\": dial tcp localhost:9115: connect: connection refused"

Julius Volz

unread,
Jan 10, 2023, 4:42:29 AM1/10/23
to Sean Coh, Prometheus Users
Hi Sean,

First of all, are you indeed running both the Blackbox Exporter and the Grafana Agent on the same host? Also, are you running both directly on the host, or in containers? If the agent is running in a container with its own network namespace, it won't see the Blackbox Exporter on the same "localhost", and you'll need to use the host's IP or host name (as reachable from within a container) instead.

Julius

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/1fd348a1-95ad-4403-8595-10480d216b3an%40googlegroups.com.


--
Julius Volz
PromLabs - promlabs.com

Sean Coh

unread,
Jan 10, 2023, 11:57:53 AM1/10/23
to Julius Volz, Prometheus Users
Well I have only ran Grafana Agent using the command line ``nohup ./grafana_agent --config.file=grafana_agent.yml &``. Which runs correctly and I can view the log output on 

``less nohup.out``. I tried running nohup with the blackbox_exporter/blackbox.yml but it keeps giving me an error “blackbox_exporter” cannot be opened because the developer cannot be verified. (Note: I'm on a Mac). I did manage to find a resource where it stated the blackbox_exporter file needs to be copied so it can be run. https://shishirkh.medium.com/monitoring-stack-setup-part-4-blackbox-exporter-f7ba54d0ed99. Would I also need to run blackbox on its own service for me to be able to scrape the metrics in grafana?


Thanks,

Sean

Brian Candler

unread,
Jan 10, 2023, 12:04:06 PM1/10/23
to Prometheus Users
Yes, you need to run blackbox_exporter separately (it will be listening on port 9115, and prometheus/grafana agent will talk to this).

To run the blackbox_exporter under macOS, after you've got the error message, go to
System Preferences > Security & Privacy > General
and click "Allow anyway". Then run it again.

Sean Coh

unread,
Jan 10, 2023, 12:31:05 PM1/10/23
to Brian Candler, Prometheus Users
I have gotten it to work. Had to make minor changes to my blackbox.yml file but it ran successfully. Thank you guys so much. The metrics are being shown in grafana as well. Really can't believe the issue was that simple.

Thanks,
Sean

Reply all
Reply to author
Forward
0 new messages