-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add unbound input plugin #3434
Add unbound input plugin #3434
Conversation
@@ -0,0 +1,3 @@ | |||
// +build windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this file out, if somehow you have unbound-control on Windows then have at it.
plugins/inputs/unbound/README.md
Outdated
### Tags: | ||
|
||
As indicated above, the prefix of a unbound stat will be used as it's 'section' tag. So section tag may have one of | ||
the following values: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like each section is very different, maybe we should call the measurement unbound_<section>
and remove the tag. If we did this we would probably want to do something special for the threadX section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is not too much data (no really need to spread information in several measurements) and I do not control unbound-control future evolution, I will start to simply drop section/tag and push all fields as they are (just converting field name dots to underscores).
I will just have a look on the "histograms" fields and see if I drop them or do something intelligible. I am not sure that these fields are really interesting for telegraf as we are collecting timeseries data... we don't really need partially pre-processed historical information.
plugins/inputs/unbound/README.md
Outdated
https://www.unbound.net/documentation/unbound-control.html for details. | ||
|
||
- unbound | ||
thread0.num.queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this section list the fields how they will be emitted from Telegraf, so thread0.num.queries
will be num.queries
.
plugins/inputs/unbound/README.md
Outdated
https://www.unbound.net/documentation/unbound-control.html for details. | ||
|
||
- unbound | ||
thread0.num.queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consider replace dots with underscores the field num_queries
so the fields fit style wise with the other plugins.
plugins/inputs/unbound/README.md
Outdated
mem.cache.message | ||
mem.mod.iterator | ||
mem.mod.validator | ||
histogram.000000.000000.to.000000.000001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these histogram metrics encoded? Is the field named 000000.000000.to.000000.000001
? Maybe we can do special processing of these, normally we use the format produced by the histogram aggregator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes actually the field name will be 000000.000000.to.000000.000001 which is not really usefful. Anyway I don't think that this kind of information is relevant for telegraf. It is easier to construct the histogram from telegraf collected data rather than using these fields. I think I will skip them from collected metrics.
plugins/inputs/unbound/unbound.go
Outdated
if len(s.Stats) == 0 { | ||
s.filter, err = filter.Compile(defaultStats) | ||
} else { | ||
// legacy support, change "all" -> "*": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have legacy support already since we are a new plugin :)
plugins/inputs/unbound/unbound.go
Outdated
// Gather collects the configured stats from unbound_stat and adds them to the | ||
// Accumulator | ||
// | ||
// The prefix of each stat (eg MAIN, MEMPOOL, LCK, etc) will be used as a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't actual sections, and there is no unbound_stat. I guess this is holdovers from an earlier version of the code, can you update it?
plugins/inputs/unbound/unbound.go
Outdated
cols := strings.Split(scanner.Text(), "=") | ||
|
||
stat := cols[0] | ||
value := cols[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could panic if somehow there are not two fields, make sure to guard against this.
plugins/inputs/unbound/unbound.go
Outdated
sectionMap[section] = make(map[string]interface{}) | ||
} | ||
|
||
sectionMap[section][field], err = strconv.ParseUint(value, 10, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parse as int64, since this is what the Accumulator holds, if there is an error parsing don't add to the fields.
plugins/inputs/unbound/unbound.go
Outdated
|
||
sectionMap[section][field], err = strconv.ParseUint(value, 10, 64) | ||
if err != nil { | ||
sectionMap[section][field], err = strconv.ParseFloat(value, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback method could switch the type of the field, which will cause the metrics to be impossible to add to InfluxDB. We may need to parse all fields as floats, or have a list of the types.
Timeout is less agresssive and configurable, tags have been removed, field name contains underscores instead of dots, field value are float64...
plugins/inputs/unbound/unbound.go
Outdated
type Unbound struct { | ||
Stats []string | ||
Binary string | ||
Timeout int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use internal.Duration
for this, it will look like timeout = "1s"
in toml.
As suggested, Timeout is now an internal.Duration object. Readme and telegraf plugin configurations have been updated accordingly. Thanks for your comments.
plugins/inputs/unbound/unbound.go
Outdated
@@ -0,0 +1,161 @@ | |||
// +build !windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this build flag, and also in the test file.
plugins/inputs/unbound/README.md
Outdated
## Glob matching can be used, ie, stats = ["total.*"] | ||
## stats may also be set to ["*"], which will collect all stats | ||
## except histogram.* statistics that will never be collected. | ||
stats = ["total.*", "num.*","time.up", "mem.*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove this filter, users can simply use the builtin fielddrop/fieldpass filters to get the same behavior.
* remove useless plugin option * adapt tests * update README and telegraf.conf
This plugin gathers stats from Unbound - a validating, recursive, and caching DNS resolver (https://www.unbound.net/)
Required for all PRs: