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

dns discovery should expose the resolved name of each record #4726

Open
depeele opened this Issue Oct 11, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@depeele
Copy link

depeele commented Oct 11, 2018

Proposal

For DNS discovery, when multiple records are returned, currently the name entry of each record is ignored, losing information that would be very useful in relabeling.

For example, using a prometheus configuration like:

scrape_configs:
  - job_name: 'controller'
    dns_sd_configs:
    - names:
      - 'tasks.controller'
      type: 'A'

In a setup where a DNS query for A records with the name tasks.controller returns:

Name:      tasks.controller
Address 1: 192.168.0.1 controller-1
Address 2: 192.168.0.2 controller-2
Address 3: 192.168.0.3 controller-3

All metrics for controller jobs will be given an instance label assigned the value of the IP address, which in many cases is ephemeral (e.g. docker swarm where the next time the service is restarted or scaled, the IP address may change).
Currently, during relabeling, the only information to work with is the IP address and the __meta_dns_name, which is set to the name specified for lookup, in this case tasks.controller.

If the name entry of each record (e.g. controller-1, controller-2, controller-3) were made available as additional metadata during relabeling, perhaps something like __meta_dns_host, it would be easy to add relabelling to associate metrics with a particular instance of a service.

scrape_configs:
  - job_name: 'controller'
    dns_sd_configs:
    - names:
      - 'tasks.controller'
      type: 'A'
    relabel_configs:
      - source_labels: [__meta_dns_host]
        target_label: instance

Changes

This seems like it would be a simple change to the refresh() function in discovery/dns/dns.go.

Remembering the addr.Target for SRV, and addr.Hdr.Name for A and AAAA records, a new __meta_dns_host entry could be included in the generated Targets.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Oct 11, 2018

A records only contain IPv4 addresses, they don't have names.

@depeele

This comment has been minimized.

Copy link
Author

depeele commented Oct 11, 2018

According to the DNS RFC, "All RRs have the same top level format", which includes NAME where:

NAME an owner name, i.e., the name of the node to which this
resource record pertains.

Defining a DNS A record within a DNS configuration follows the form:

<host>     IN     A     <IP-address>

Here, <host> will be the value reported in the NAME portion of the RR representing that DNS entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.