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

Support using MX records for DNS discovery #10099

Merged
merged 1 commit into from
Aug 3, 2022
Merged

Conversation

dgl
Copy link
Member

@dgl dgl commented Jan 2, 2022

It's currently possible to use blackbox_exporter to probe MX records
themselves. However it's not possible to do an end-to-end test, like is
possible with SRV records. This makes it possible to use MX records as a
source of hostnames in the same way as SRV records.

Signed-off-by: David Leadbeater dgl@dgl.cx

@roidelapluie
Copy link
Member

I would require a port. I expect that nowadays 587 is most used.

@dgl
Copy link
Member Author

dgl commented Jan 3, 2022

Not really, 25 is still the standard for email delivery rather than submission; so if you publish MX records you're telling people a service is available on port 25, so the default makes sense.

@beorn7
Copy link
Member

beorn7 commented Jan 5, 2022

Reminder: In a week (on 2022-01-12), I'll cut a new release (v2.33). I think this PR would be great to go into the release, so it would be good if the review could be concluded soon.

Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@roidelapluie
Copy link
Member

How can we phrase the documentation to say that the MX port can still be overwritten?

@dgl
Copy link
Member Author

dgl commented Jan 10, 2022

I changed it to just be quite explicit:

# The port number used if the query type is not SRV. For MX set to override the
# default (25).
[ port: <int>]

wdyt?

@roidelapluie
Copy link
Member

I have been thinking about this and I am really not sure we should make an execption for MX records to have a default port. Just like we do not default to 80 for A records. This adds complexity and most users would use an exporter rather that something directly on port 25. From a user perspective, it is easy to add port: 25 in the config if required.

@dgl
Copy link
Member Author

dgl commented Jan 13, 2022

I think the difference there is A doesn't imply HTTP, unlike MX which does imply SMTP.

But also I don't really mind if you prefer to make port required, I suspect this is a bit niche anyway and having 25 documented in the config doesn't hurt, even if anything other than 25 is very unlikely.

@roidelapluie
Copy link
Member

Yes, my preference is no default port.

Note that Postfix exporter runs on 9154, and Dovecot exporter on 9166.

case "A", "AAAA":
if c.Port == 0 {
return errors.New("a port is required in DNS-SD configs for all record types except SRV")
return errors.New("a port is required in DNS-SD configs for all record types except SRV and MX")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is no longer necessary

@@ -99,10 +101,10 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return errors.New("DNS-SD config must contain at least one SRV record name")
}
switch strings.ToUpper(c.Type) {
case "SRV":
case "SRV", "MX":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is no longer necessary

@@ -129,18 +131,21 @@ func NewDiscovery(conf SDConfig, logger log.Logger) *Discovery {
}

qtype := dns.TypeSRV
port := conf.Port
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is no longer necessary

@@ -40,6 +40,8 @@ const (
dnsSrvRecordPrefix = model.MetaLabelPrefix + "dns_srv_record_"
dnsSrvRecordTargetLabel = dnsSrvRecordPrefix + "target"
dnsSrvRecordPortLabel = dnsSrvRecordPrefix + "port"
dnsMxRecordPrefix = model.MetaLabelPrefix + "dns_mx_record_"
dnsMxRecordTargetLabel = dnsMxRecordPrefix + "target"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about we also expose the priority?

@roidelapluie
Copy link
Member

Friendly ping :)

It's currently possible to use blackbox_exporter to probe MX records
themselves. However it's not possible to do an end-to-end test, like is
possible with SRV records. This makes it possible to use MX records as a
source of hostnames in the same way as SRV records.

Signed-off-by: David Leadbeater <dgl@dgl.cx>
@roidelapluie
Copy link
Member

This LGTM, can you rebase?

@roidelapluie roidelapluie enabled auto-merge (squash) August 3, 2022 09:02
@roidelapluie roidelapluie merged commit d677ec4 into prometheus:main Aug 3, 2022
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this pull request Aug 14, 2022
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this pull request Aug 14, 2022
Mama59 pushed a commit to Arnoways/prometheus that referenced this pull request Aug 25, 2022
It's currently possible to use blackbox_exporter to probe MX records
themselves. However it's not possible to do an end-to-end test, like is
possible with SRV records. This makes it possible to use MX records as a
source of hostnames in the same way as SRV records.

Signed-off-by: David Leadbeater <dgl@dgl.cx>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants