Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus not reading blackbox targets from file_sd_configs

I'm configuring blackbox for monitoring my websites. Prometheus static config targets are working but are also little bit messy. I would to put all my targets into file but its not working at all.

docker-compose:

version: '2.1'

volumes:
  prometheus_data: {}

services:
  prometheus:
    mem_limit: 1000m
    image: prom/prometheus
    container_name: prometheus
    volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.retention.time=200h'
    links:
      - 'blackbox:blackbox'
    expose:
      - 9090
    labels:
      container_group: monitoring

  blackbox:
    image: prom/blackbox-exporter
    container_name: blackbox
    expose:
      - 9115
    volumes:
      - ./blackbox/:/etc/blackbox/
    command: --config.file=/etc/blackbox/blackbox.yml
    labels:
      container_group: monitoring

prometheus.yml

scrape_configs:

  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx]
       file_sd_configs:
      - files: ['/blackbox/blackbox_targets.yml']
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: blackbox:9115

blackbox_targets.yml

- targets: ['http://google.com']
  labels:
    group: 'localhost'
    instance: 'localhost'

Without blackbox_targets.yml can see targets in prometheus bat leter on are missing.

like image 456
MrNetroful Avatar asked Jan 24 '26 03:01

MrNetroful


1 Answers

In your prometheus.yml config file, the file location /blackbox/blackbox_targets.yml is invalid. Depending on where the file actually lives on the host comnputer, you need to make sure that a) it's mapped into the container and b) that you use the right path in the config file.

For instance, if the file lives in ./prometheus/ folder on your host computer then the path should be /etc/prometheus/blackbox_targets.yml instead.

like image 63
Oliver Avatar answered Jan 27 '26 00:01

Oliver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!