-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Metricbeat: Add munin module #6517
Conversation
metricbeat/module/munin/munin.go
Outdated
return n, err | ||
} | ||
|
||
// Releases node connection resources |
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.
comment on exported method Node.Close should be of the form "Close ..."
metricbeat/module/munin/munin.go
Outdated
reader *bufio.Reader | ||
} | ||
|
||
// Connects with a munin node |
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.
comment on exported function Connect should be of the form "Connect ..."
metricbeat/module/munin/munin.go
Outdated
unknownValue = "U" | ||
) | ||
|
||
// Munin node client |
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.
comment on exported type Node should be of the form "Node ..." (with optional leading article)
45757a0
to
441345c
Compare
jenkins, test it |
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.
Awesome new module! 🎉
I left some comments. It would be nice to generate an example data.json
. have a look to make generate-json
continue | ||
} | ||
if f, err := strconv.ParseFloat(value, 64); err == nil { | ||
event.Put(key, f) |
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.
for the record, this is a candidate for safemapstr.Put
: #6434 as soon as it's in
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.
FYI, the PR went in already, so you can update these :)
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.
Good point, but I think dots are not allowed in munin metric names.
We could use safemapstr
in any case to protect metricbeat against incorrect implementations of munin nodes or plugins, wdyt?
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'm wondering if the float parsing will make a difference in ES. If we have a value 3 and we parse it it will still put 3 into the event and on the ES side it will assume it's an integer so conflicts will happen afterwards. Sounds like a good use case for the local fields definitions.
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.
Umm, so what do you recommend to do here?
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've checked metrics format, sounds like we don't need safemapstr.Put
here
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 what I'm getting at we could even skip this code part here and it would make no difference? If someone wants to make sure the mapping is correct he has to use #6024
Please double check the above statement as I don't know much about the munin output.
event.Put(key, f) | ||
continue | ||
} | ||
event.Put(key, value) |
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.
safemapstr.Put
too
metricbeat/module/munin/node/node.go
Outdated
config := struct{}{} | ||
if err := base.Module().UnpackConfig(&config); err != nil { | ||
return nil, err | ||
} |
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 guess this is not needed, as there is no custom config to parse?
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.
Actually there is no custom config so far, I'll remove this.
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 have finally kept it to support namespaces.
metricbeat/module/munin/munin.go
Outdated
} | ||
// Cosume and ignore first line returned by munin, it is a comment | ||
// about the node | ||
bufio.NewScanner(n.reader).Scan() |
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.
Should we check for the return value here? In case of false
we should probably check the Err
method for the error.
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, I will return scanner.Error()
.
} | ||
|
||
scanner := bufio.NewScanner(n.reader) | ||
scanner.Scan() |
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.
Should we also check here the return value?
|
||
scanner := bufio.NewScanner(n.reader) | ||
scanner.Scan() | ||
return strings.Fields(scanner.Text()), scanner.Err() |
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 see you run here scanner.Err()
which makes the return value check obsolete before.
} | ||
|
||
// Fetch method implements the data gathering | ||
func (m *MetricSet) Fetch() (common.MapStr, error) { |
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 if this metricset is used for different host, the returned data can contain very different structures. We should allow to set the namespace for this metricset as we do for example for the http/json metricset to make sure users can choose their namespace to prevent field conflicts.
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.
Ok, adding namespace.
@@ -0,0 +1,60 @@ | |||
package node |
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.
You wrote above that metricbeat is the master in this scenario so I was tempted to say we should call the default namespace master
. But as it's about the data from the node (is that naming correct?) +1 on node.
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.
Protocol-wise we are like implementing the server side, but the metrics on the metricset are about the node, so +1 too to node :)
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.
LGTM. Left some minor comments.
hosts: ["localhost:4949"] | ||
--- | ||
|
||
All metrics exposed by a single munin node will be sent as an only event, |
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.
"All metrics exposed by a single munin node will be sent in a single event, grouped by munin items." ?
An example here would be nice.
metricsets: ["node"] | ||
enabled: false | ||
period: 10s | ||
hosts: ["localhost:4949"] |
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.
The namespace config should be an option here.
metricbeat/module/munin/node/node.go
Outdated
cfgwarn.Experimental("The munin node metricset is experimental.") | ||
|
||
config := struct { | ||
Namespace string `config:"namespace" validate:"required"` |
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 know this is not the case in the other implementations but we should prefix all configs with the metricset to make sure it's obvious to which metricset they belong. So this should be node.namespace
.
metricsets: ["node"] | ||
enabled: false | ||
period: 10s | ||
hosts: ["localhost:4949"] |
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.
Add namespace config.
metricsets: ["node"] | ||
enabled: false | ||
period: 10s | ||
hosts: ["localhost:4949"] |
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.
Add namespace config
Added namespace config where it was missing, and renamed it to |
I still have to take a look to the |
@ruflin, after changing from I have seen in the base template that it expects the namespace to be in
Is this ok? |
Add munin module, with node metricset that obtain metrics from a running munin node using the same protocol used by munin masters.
The extras is fine to solve the CI issue. I'm going forth and back if namespace should be prefix by the metricset or not. The reason I like to have it prefix is that we do that will all metricset specific configs. Like this it becomes obvious to which metricset it belongs and does not accidentially overlap with other metricsets configs. Probably the reason we have it globally is that "dynamic" metricsets like this one should also be configured alone, meaning that the list of metricsets enable in a module should only contain this one. We don't enforce this yet but probably should. Like this an overlap cannot happen. Having the namespace config option on the module level could allow us to make it supported in a generic way and not have to implement it in each module. @exekias @andrewkroh Any thoughts here? |
I merged the PR to have the munin module in. The discussion about the naming of the |
Add module to export metrics from munin nodes (#6473). It can obtain metrics from any agent that implements the basic protocol for data exchange between master and nodes. Under the terms of this protocol, metricbeat would be acting as a master.