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] Allow to specify query Class #635

Merged
merged 2 commits into from
Jun 14, 2020

Conversation

Annih
Copy link
Contributor

@Annih Annih commented Jun 6, 2020

Context
In some cases we might want to probe other DNS class than the INET one; for instance we could probe the server version often exposed in a TXT CH version.bind record.

This PR offers the ability to do so by setting query_class in your prober configuration, the default is "IN" as it was before.

Implementation note
Most of the code is a copy/paste/replace of the query_type setting; except that the setQuestion call has been replaced by its "slightly more verbose, but more flexible" alternative.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

LGTM

example.yml Outdated Show resolved Hide resolved
var ok bool
qc, ok = dns.StringToClass[module.DNS.QueryClass]
if !ok {
level.Error(logger).Log("msg", "Invalid query class", "Class seen", module.DNS.QueryClass, "Existing classes", dns.ClassToString)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be done in the config so that it can be caught when the config is loaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that mean the QueryType check L148 (should be also done in the config?
Would you accept a 2nd PR to move both checks outside this file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, it should be. It's a small enough change it can all be done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, sorry for the delay.
I added config checks but also kept the existing code in the prober.

CONFIGURATION.md Outdated Show resolved Hide resolved
Signed-off-by: Baptiste Courtois <[email protected]>
@brian-brazil
Copy link
Contributor

Did you get a chance to make that final change? I'd like to get a release out soon and would like to include this PR.

This allows to catch simple config errors earlier.

Signed-off-by: Baptiste Courtois <[email protected]>
@brian-brazil brian-brazil merged commit a289888 into prometheus:master Jun 14, 2020
@brian-brazil
Copy link
Contributor

Thanks!

@Annih Annih deleted the dns_classes branch June 16, 2020 17:02
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.

3 participants