Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting multiple DNS records #51

Closed
mattbostock opened this issue Jul 19, 2016 · 9 comments
Closed

Targeting multiple DNS records #51

mattbostock opened this issue Jul 19, 2016 · 9 comments

Comments

@mattbostock
Copy link
Contributor

@mattbostock mattbostock commented Jul 19, 2016

The DNS prober currently allows a DNS name to be configured statically in blackbox_exporter's YAML configuration file. The target, specified by Prometheus, is the nameserver to query. This diverges from @brian-brazil's suggestion to make the DNS name part of the query string (rather than the nameserver).

This favours probing the same DNS record from multiple DNS servers, and makes probing multiple DNS records from the same namesever rather cumbersome.

Realistically I think both use cases are going to be common, depending on whether you're running DNS servers or just want to make sure that your SRV records are working correctly, for example.

That said, I think probing multiple records against the same nameserver is possibly the most common case, and configuring a DNS modules per nameserver should be less cumbersome than one per DNS record.

Interested if @knyar has any suggestions on how to handle this.

@brian-brazil

This comment has been minimized.

Copy link
Member

@brian-brazil brian-brazil commented Jul 19, 2016

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.

@mattbostock

This comment has been minimized.

Copy link
Contributor Author

@mattbostock mattbostock commented Jul 19, 2016

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

@knyar

This comment has been minimized.

Copy link
Contributor

@knyar knyar commented Jul 19, 2016

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.

@mattbostock

This comment has been minimized.

Copy link
Contributor Author

@mattbostock mattbostock commented Jul 20, 2016

Makes sense, thanks both!

@jmartin127

This comment has been minimized.

Copy link

@jmartin127 jmartin127 commented Aug 17, 2016

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.

@brian-brazil

This comment has been minimized.

Copy link
Member

@brian-brazil brian-brazil commented Aug 17, 2016

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.

@bweston92

This comment has been minimized.

Copy link

@bweston92 bweston92 commented Feb 20, 2017

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?

@brian-brazil

This comment has been minimized.

Copy link
Member

@brian-brazil brian-brazil commented Feb 20, 2017

You can use relabelling on the module url parameter.

@mancubus77

This comment has been minimized.

Copy link

@mancubus77 mancubus77 commented Apr 28, 2018

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.