Skip to content

Commit

Permalink
Add probe_dns_flag_ad metric
Browse files Browse the repository at this point in the history
This adds reporting of the Authenticated Data flag, indicating whether
the resolver thinks the resource is properly signed with DNSSEC.

Ref #551

Signed-off-by: Kim Alvefur <zash@zash.se>
  • Loading branch information
Zash committed Nov 6, 2024
1 parent 22ccef7 commit bd42875
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions prober/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry
Name: "probe_dns_additional_rrs",
Help: "Returns number of entries in the additional resource record list",
})
probeDNSFlagAd := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "probe_dns_flag_ad",
Help: "Returns whether or not the query had the DNSSEC AD flag set",
})
probeDNSQuerySucceeded := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "probe_dns_query_succeeded",
Help: "Displays whether or not the query was executed successfully",
Expand All @@ -154,6 +158,7 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry
registry.MustRegister(probeDNSAnswerRRSGauge)
registry.MustRegister(probeDNSAuthorityRRSGauge)
registry.MustRegister(probeDNSAdditionalRRSGauge)
registry.MustRegister(probeDNSFlagAd)
registry.MustRegister(probeDNSQuerySucceeded)

qc := uint16(dns.ClassINET)
Expand Down Expand Up @@ -255,6 +260,7 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry
msg := new(dns.Msg)
msg.Id = dns.Id()
msg.RecursionDesired = module.DNS.Recursion
msg.AuthenticatedData = true
msg.Question = make([]dns.Question, 1)
msg.Question[0] = dns.Question{dns.Fqdn(module.DNS.QueryName), qt, qc}

Expand All @@ -280,6 +286,12 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry
probeDNSAdditionalRRSGauge.Set(float64(len(response.Extra)))
probeDNSQuerySucceeded.Set(1)

if response.AuthenticatedData {
probeDNSFlagAd.Set(1)
} else {
probeDNSFlagAd.Set(0)
}

if qt == dns.TypeSOA {
probeDNSSOAGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "probe_dns_serial",
Expand Down

0 comments on commit bd42875

Please sign in to comment.