Giter Club home page Giter Club logo

Comments (12)

mancubus77 avatar mancubus77 commented on May 15, 2024 32

just in case someone will need to solve same issue:
blackbox.yml

modules:
  facebook.com:
    prober: dns
    timeout: 5s
    dns:
      query_name: "facebook.com"
      query_type: "A"
      preferred_ip_protocol: "ip4"
  imdb.com:
    prober: dns
    timeout: 5s
    dns:
      query_name: "imdb.com"
      query_type: "A"
      preferred_ip_protocol: "ip4"

prometheus scrape

  - job_name: 'blackbox-dns'
    scrape_interval: 30s
    metrics_path: /probe
    static_configs:
      - targets:
        - facebook.com:8.8.8.8
        - imdb.com:8.8.8.8
        - facebook.com:1.1.1.1
        - imdb.com:1.1.1.1
        - facebook.com:127.0.0.1
        - imdb.com:127.0.0.1
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - source_labels: [__param_target]
        regex: '(.*):.*$'
        replacement: '$1'
        target_label: 'domain'
      - source_labels: [__param_target]
        regex: '.*:(.*)$'
        replacement: '$1'
        target_label: 'instance'
      - source_labels: [__param_target]
        regex: '(.*):.*$'
        replacement: '$1'
        target_label: __param_module
      - source_labels: [__param_target]
        regex: '.*:(.*)$'
        replacement: '$1'
        target_label: __param_target
      - target_label: __address__
        replacement: 172.17.0.1:9115  # The blackbox exporter's real hostname:port.

from blackbox_exporter.

robodair avatar robodair commented on May 15, 2024 5

This was the top of my google search for "blackbox dns poll multiple domains prometheus" and I found @mancubus77's comment very helpful, I've improved his example Prometheus configuration slightly and would like to share it so everyone can benefit:

- job_name: blackbox_dns
  metrics_path: /probe
    relabel_configs:
  # You can set internal labels that are called __param_<name>.
  # Those set URL parameter with the key <name> for the scrape request.
  # https://prometheus.io/docs/guides/multi-target-exporter/

  # Populate domain label with domain portion of __address__
  - source_labels: [__address__]
    regex: (.*):.*$
    replacement: $1
    target_label: domain
  # Populate instance label with dns server IP portion of __address__
  - source_labels: [__address__]
    regex: .*:(.*)$
    replacement: $1
    target_label: instance
  # Populate module URL parameter with domain portion of __address__
  # This is a parameter passed to the blackbox exporter
  - source_labels: [domain]
    target_label: __param_module
  # Populate target URL parameter with dns server IP
  - source_labels: [instance]
    target_label: __param_target
  # Populate __address__ with the address of the blackbox exporter to hit
  - target_label: __address__
    # Real address of blackbox exporter (Assumed to be running on port 9115 on localhost)
    replacement: 127.0.0.1:9115
  static_configs:
  - targets:
    - facebook.com:8.8.8.8
    - google.com:8.8.8.8
    - imdb.com:8.8.8.8
    - facebook.com:1.1.1.1
    - google.com:1.1.1.1
    - imdb.com:1.1.1.1
    - facebook.com:127.0.0.1
    - google.com:127.0.0.1
    - imdb.com:127.0.0.1

See https://prometheus.io/docs/guides/multi-target-exporter/ for the official docs.

from blackbox_exporter.

jmartin127 avatar jmartin127 commented on May 15, 2024 4

I can see @knyar's point regarding the module configuration and customization.

However, I also agree with @mattbostock that it is probably more common to want to probe multiple DNS records against the same DNS server. For example, in my case, I want to probe 54 DNS records against 2 DNS servers. But with the current implementation, I find myself writing a Perl script to generate the 54 modules in my blackbox.yaml config. I then also have to generate 54 Prometheus scrape jobs to scrape each module.

Is there an easier way for me to accomplish this? Or is auto-generating really the way to go? Thanks in advance.

from blackbox_exporter.

mattbostock avatar mattbostock commented on May 15, 2024 3

@brian-brazil To query multiple records then, would you expect to create a module for each one?

from blackbox_exporter.

mydevice avatar mydevice commented on May 15, 2024 1

@mancubus77 Hello, i take your example but now i want to use Grafana to create a percentage graph based on the values 1 & 0. Do you have the equation ?

from blackbox_exporter.

brian-brazil avatar brian-brazil commented on May 15, 2024

I think this way around is correct, and is similar to how all the other modules work. Each configured module is one type of test to run against some to-be-specified server.

from blackbox_exporter.

knyar avatar knyar commented on May 15, 2024

I agree with the "one type of test" argument.

Also, keep in mind that any validation options specified in DNSProbe are often only going to be useful in the context of a specific query_name and query_type - i.e. you would check that your MX record contains your mail server, and that your DNS balancer returns a low TTL for your dynamic records.

Since you normally would want to keep prometheus server configuration in sync with blackbox_exporter anyway (you actually need to use the modules you defined), you are hopefully using a higher level abstraction to generate config files for both. This means that the number of modules that end up in the config file does not practically matter.

from blackbox_exporter.

mattbostock avatar mattbostock commented on May 15, 2024

Makes sense, thanks both!

from blackbox_exporter.

brian-brazil avatar brian-brazil commented on May 15, 2024

Auto-generation is the way to go.

The expected use case is that you'll run one or two tests against hundreds or thousands of servers. Attempting to go the other via HTTP params wouldn't be sane, there's too many possibilities.

from blackbox_exporter.

bweston92 avatar bweston92 commented on May 15, 2024

So I've got my different probe configurations, one for each domain. How can I relabel so that I can change the query param for probe which each domain against each target?

from blackbox_exporter.

brian-brazil avatar brian-brazil commented on May 15, 2024

You can use relabelling on the module url parameter.

from blackbox_exporter.

UAnton avatar UAnton commented on May 15, 2024

Hi,
How can I check multiple MX records (200+)? I try manual from https://www.robustperception.io/probing-dns-servers-with-the-blackbox-exporter, but can't check status in Grafana, because blackbox don't sent domain name and I can't filtering. Thanks.

from blackbox_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.