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

missing types in bind plugin #6094

Closed
MorphBonehunter opened this issue Jul 9, 2019 · 6 comments · Fixed by #6123
Closed

missing types in bind plugin #6094

MorphBonehunter opened this issue Jul 9, 2019 · 6 comments · Fixed by #6123
Labels
feature request Requests for new plugin and for new features to existing plugins
Milestone

Comments

@MorphBonehunter
Copy link

MorphBonehunter commented Jul 9, 2019

Relevant telegraf.conf:

[[inputs.bind]]
  ## An array of BIND XML statistics URI to gather stats.
  ## Default is "http://localhost:8053/xml/v3".
  urls = ["http://localhost:8053/json/v1"]
  # gather_memory_contexts = false
  # gather_views = false

System info:

Using Telegraf 1.11.1 on Arch Linux with BIND 9.14.3

Steps to reproduce:

Today i played with the bind plugin and noticed that there are two missing types in the telegraf output.
Based on the example output there are 6 types on the bind_counter measurement, in my case type=rcode and type=zonestat are missing.

I've try to look at the source code and i can not find the place where this is collected.
In json_stats.go there are only the 4 types mentioned, which i can also see.

Expected behavior:

The type=rcode and type=zonestat should collected.

Actual behavior:

Only type=opcode, type=qtype, type=nsstat and type=sockstat are collected.

Additional info:

telegraf output (telegraf --config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d/ --input-filter bind -test):

2019-07-09T12:22:01Z I! Starting Telegraf 1.11.1
> bind_counter,host=evelyn,port=8053,source=localhost,type=opcode,url=localhost:8053 IQUERY=0i,NOTIFY=5i,QUERY=1921i,STATUS=0i,UPDATE=0i 1562674922000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=qtype,url=localhost:8053 A=1050i,AAAA=844i,NS=20i,PTR=6i,SOA=1i 1562674922000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=nsstat,url=localhost:8053 QryAuthAns=1229i,QryNXDOMAIN=189i,QryNoauthAns=686i,QryNxrrset=335i,QryRecursion=233i,QrySERVFAIL=6i,QrySuccess=1391i,QryUDP=1918i,ReqEdns0=205i,Requestv4=1926i,RespEDNS0=205i,Response=1926i 1562674922000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=sockstat,url=localhost:8053 RawActive=1i,RawOpen=1i,TCP4Accept=7i,TCP4Active=9i,TCP4Close=73i,TCP4Conn=68i,TCP4Open=75i,UDP4Active=20i,UDP4Close=750i,UDP4Conn=743i,UDP4Open=770i 1562674922000000000
> bind_memory,host=evelyn,port=8053,source=localhost,url=localhost:8053 block_size=23855104i,context_size=5193328i,in_use=4937656i,lost=0i,total_use=34981007i 1562674922000000000

Bind JSON Output (curl http://localhost:8053/json/v1/server, the /server is only used in the curl to limit the output, full output is >19k lines):

{
  "json-stats-version":"1.5",
  "boot-time":"2019-07-09T12:02:47.822Z",
  "config-time":"2019-07-09T12:02:47.893Z",
  "current-time":"2019-07-09T12:22:58.935Z",
  "version":"9.14.3",
  "opcodes":{
    "QUERY":1933,
    "IQUERY":0,
    "STATUS":0,
    "RESERVED3":0,
    "NOTIFY":5,
    "UPDATE":0,
    "RESERVED6":0,
    "RESERVED7":0,
    "RESERVED8":0,
    "RESERVED9":0,
    "RESERVED10":0,
    "RESERVED11":0,
    "RESERVED12":0,
    "RESERVED13":0,
    "RESERVED14":0,
    "RESERVED15":0
  },
  "rcodes":{
    "NOERROR":1732,
    "FORMERR":0,
    "SERVFAIL":6,
    "NXDOMAIN":200,
    "NOTIMP":0,
    "REFUSED":0,
    "YXDOMAIN":0,
    "YXRRSET":0,
    "NXRRSET":0,
    "NOTAUTH":0,
    "NOTZONE":0,
    "RESERVED11":0,
    "RESERVED12":0,
    "RESERVED13":0,
    "RESERVED14":0,
    "RESERVED15":0,
    "BADVERS":0,
    "17":0,
    "18":0,
    "19":0,
    "20":0,
    "21":0,
    "22":0,
    "BADCOOKIE":0
  },
  "qtypes":{
    "A":1062,
    "NS":20,
    "SOA":1,
    "PTR":6,
    "AAAA":844
  },
  "nsstats":{
    "Requestv4":1938,
    "ReqEdns0":217,
    "Response":1938,
    "RespEDNS0":217,
    "QrySuccess":1391,
    "QryAuthAns":1229,
    "QryNoauthAns":698,
    "QryNxrrset":336,
    "QrySERVFAIL":6,
    "QryNXDOMAIN":200,
    "QryRecursion":241,
    "QryUDP":1930
  },
  "zonestats":{
    "NotifyOutv4":8,
    "NotifyInv4":5,
    "SOAOutv4":5
  },
  "views":{
    "_default":{
      "resolver":{
        "stats":{
          "Queryv4":829,
          "Responsev4":813,
          "NXDOMAIN":312,
          "SERVFAIL":24,
          "Truncated":68,
          "Retry":292,
          "QueryTimeout":16,
          "GlueFetchv4":119,
          "GlueFetchv4Fail":3,
          "ValAttempt":458,
          "ValOk":70,
          "ValNegOk":388,
          "QryRTT10":22,
          "QryRTT100":589,
          "QryRTT500":202,
          "BucketSize":31,
          "ClientCookieOut":582,
          "ServerCookieOut":45,
          "CookieIn":78,
          "CookieClientOk":78,
          "BadCookieRcode":1,
          "Priming":1
        },
        "qtypes":{
          "A":722,
          "NS":2,
          "AAAA":42,
          "DS":44,
          "DNSKEY":19
        },
        "cache":{
          "A":463,
          "NS":85,
          "CNAME":18,
          "SOA":28,
          "AAAA":211,
          "DS":32,
          "RRSIG":93,
          "NSEC":4,
          "DNSKEY":11,
          "!A":16,
          "!AAAA":2,
          "!DS":19,
          "NXDOMAIN":179
        },
        "cachestats":{
          "CacheHits":4206,
          "CacheMisses":16,
          "QueryHits":792,
          "QueryMisses":275,
          "DeleteLRU":0,
          "DeleteTTL":32,
          "CacheNodes":513,
          "CacheBuckets":259,
          "TreeMemTotal":543728,
          "TreeMemInUse":250440,
          "TreeMemMax":261248,
          "HeapMemTotal":393216,
          "HeapMemInUse":132096,
          "HeapMemMax":132096
        },
        "adb":{
          "nentries":1021,
          "entriescnt":375,
          "nnames":1021,
          "namescnt":392
        }
      }
    },
    "_bind":{
      "resolver":{
        "stats":{
          "BucketSize":31
        },
        "qtypes":{
        },
        "cache":{
        },
        "cachestats":{
          "CacheHits":0,
          "CacheMisses":0,
          "QueryHits":0,
          "QueryMisses":0,
          "DeleteLRU":0,
          "DeleteTTL":0,
          "CacheNodes":0,
          "CacheBuckets":64,
          "TreeMemTotal":279512,
          "TreeMemInUse":21728,
          "TreeMemMax":21728,
          "HeapMemTotal":262144,
          "HeapMemInUse":1024,
          "HeapMemMax":1024
        },
        "adb":{
          "nentries":1021,
          "nnames":1021
        }
      }
    }
  }
}
@glinton glinton added the feature request Requests for new plugin and for new features to existing plugins label Jul 9, 2019
@glinton
Copy link
Contributor

glinton commented Jul 9, 2019

Is /json/v1/server supported in the telegraf config as an item in urls? looks like it only takes /json/v1 in the plugin

@MorphBonehunter
Copy link
Author

Hey @glinton, as you can see in my telegraf.conf i don't use the /json/v1/server in the plugin.
This was only to demonstrate that the information is in the json output and to limit the output (the full output has over 19k lines)
I've edited my initial comment to make this clear.

@MorphBonehunter
Copy link
Author

@glinton maybe another question...you added the "feature request" label but is this really a feature request?
In the the example output the two missing measurements are present, so i thought this is an bug or is the example the wrong one?

@danielnelson
Copy link
Contributor

@MorphBonehunter Doesn't look like we ever had any code to parse rcodes or zonestats in json, however maybe the xml variant handles it dynamically. It's one of those bug/feature middle ground items, but the distinction isn't super important here. If you can verify this fix we can include it in the next patch release:

@MorphBonehunter
Copy link
Author

@danielnelson thanks for the explanation, indeed i only look at the json code.
I can confirm your code additions work:

telegraf version
Telegraf unknown (git: bind-rcode-zonestats 24d63ab7)

telegraf --config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d/ --input-filter bind -test 
2019-07-16T06:56:48Z I! Starting Telegraf 
> bind_counter,host=evelyn,port=8053,source=localhost,type=opcode,url=localhost:8053 IQUERY=0i,NOTIFY=4i,QUERY=121102i,STATUS=0i,UPDATE=0i 1563260208000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=rcodes,url=localhost:8053 17=0i,18=0i,19=0i,20=0i,21=0i,22=0i,BADCOOKIE=0i,BADVERS=0i,FORMERR=0i,NOERROR=107624i,NOTAUTH=0i,NOTIMP=0i,NOTZONE=0i,NXDOMAIN=13029i,NXRRSET=0i,REFUSED=12i,RESERVED11=0i,RESERVED12=0i,RESERVED13=0i,RESERVED14=0i,RESERVED15=0i,SERVFAIL=384i,YXDOMAIN=0i,YXRRSET=0i 1563260208000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=qtype,url=localhost:8053 A=66558i,AAAA=52788i,ANY=6i,IXFR=4i,MX=131i,NS=1292i,PTR=100i,SOA=200i,TXT=23i 1563260208000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=nsstat,url=localhost:8053 Prefetch=53i,QryAuthAns=75639i,QryDuplicate=53i,QryFailure=12i,QryNXDOMAIN=13029i,QryNoauthAns=45010i,QryNxrrset=20830i,QryRecursion=14240i,QrySERVFAIL=384i,QrySuccess=86790i,QryTCP=2i,QryUDP=121084i,RecQryRej=12i,ReqEdns0=13697i,ReqTCP=8i,Requestv4=121106i,RespEDNS0=13644i,Response=121049i,XfrReqDone=4i 1563260208000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=sockstat,url=localhost:8053 RawActive=1i,RawOpen=1i,TCP4Accept=12i,TCP4Active=8i,TCP4Close=1051i,TCP4Conn=1034i,TCP4Open=1047i,TCP4RecvErr=1i,UDP4Active=20i,UDP4BindFail=25i,UDP4Close=33530i,UDP4Conn=33371i,UDP4Open=33550i,UDP4RecvErr=241i 1563260208000000000
> bind_counter,host=evelyn,port=8053,source=localhost,type=zonestats,url=localhost:8053 IXFRReqv4=2i,NotifyInv4=4i,NotifyOutv4=12i,NotifyRej=2i,SOAOutv4=126i,XfrSuccess=2i 1563260208000000000
> bind_memory,host=evelyn,port=8053,source=localhost,url=localhost:8053 block_size=25952256i,context_size=5370928i,in_use=5518444i,lost=0i,total_use=306780226i 1563260208000000000

But i like to mention that all other types are singular and your code addition adds the two types as plural. Also the XML Output is singular so i think it would be better to use rcode than rcodes and zonestat than zonestats.

@danielnelson
Copy link
Contributor

Good call, I'll make that change.

@danielnelson danielnelson added this to the 1.11.3 milestone Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants