-
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
Kubernetes module for metricbeat #3916
Conversation
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
1 similar comment
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
metricbeat/include/list.go
Outdated
@@ -28,6 +28,8 @@ import ( | |||
_ "github.com/elastic/beats/metricbeat/module/docker/info" | |||
_ "github.com/elastic/beats/metricbeat/module/docker/memory" | |||
_ "github.com/elastic/beats/metricbeat/module/docker/network" | |||
_ "github.com/elastic/beats/metricbeat/module/dropwizard" | |||
_ "github.com/elastic/beats/metricbeat/module/dropwizard/collector" |
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.
probably these are spurious :)
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.
removed
63ca4f9
to
8a7933a
Compare
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 left some minor comments.
metricbeat/metricbeat.full.yml
Outdated
metricsets: ["node","container","volume","pod","system"] | ||
enabled: true | ||
period: 10s | ||
hosts: ["localhost"] |
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.
What is the default port?
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.
done
metricbeat/metricbeat.full.yml
Outdated
@@ -179,6 +179,14 @@ metricbeat.modules: | |||
#username: "" | |||
#password: "" | |||
|
|||
#------------------------------- kubelet Module ------------------------------ | |||
- module: kubelet |
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 be commented out so it is not enabled by default.
metricbeat/metricbeat.yml
Outdated
@@ -46,6 +46,14 @@ metricbeat.modules: | |||
period: 10s | |||
processes: ['.*'] | |||
|
|||
#------------------------------- kubelet Module ------------------------------ |
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 can use short_config: false
in the module fields.yml so it is not added to the short config.
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.
done
@@ -0,0 +1,96 @@ | |||
package collector |
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.
dropwizard? Is that here intentional? Sounds like an other potential module for the future :-)
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.
removed. added it by mistake to this PR. it is the next one ;)
- key: kubelet | ||
title: "kubelet" | ||
description: > | ||
kubelet Module |
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 add []beta
flag and short_config: false
here? See https://github.com/elastic/beats/blob/master/metricbeat/module/docker/_meta/fields.yml#L7 for an example.
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.
done.
"start_time": container.StartTime, | ||
|
||
"cpu": common.MapStr{ | ||
"usage.nanocores": container.CPU.UsageNanoCores, |
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.
That should be "usage": common.MapStr{ "nanocores" }
. The reason is otherwise it will break with elasticsearch 2.x. We often use `common.MapStr.Put(...) in these cases as it does it automatically, but not sure how we could use this 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.
done
for _, container := range pod.Containers { | ||
containerEvent := common.MapStr{ | ||
mb.ModuleData: common.MapStr{ | ||
"pod": common.MapStr{ |
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.
Seems like the schema
package could be used here to do the mapping. Can also be done later.
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.
schema wouldnt work because the input interface coming from the HTTP has arrays.
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. What I did in other metricsets is using multiple schemas. Means doing the array "manually" and then under it having schemas. But we can look into it after the first version.
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 what your saying.
}, | ||
|
||
"memory": common.MapStr{ | ||
"available.bytes": node.Memory.AvailableBytes, |
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.
See comments above about schema and 2.x
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.
done
4f27f0a
to
463cf96
Compare
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 had a look again at the code and I think most of the basic things are there that we need. To split future work I suggest we move forward with this PR and create a follow up Github issue to track the open tasks. Some of the tasks I currently see:
- Complete
fields.yml
files with all fields - Add system tests to check if all fields are documented
- Add tests -> this is trickiers, as probably can't run a kubelet easily to do integration tests? Using a mock golang http service could be used to just returns predefined json docs?
- Check fields again if they follow the conventions
- Add more documentation on how to use it etc.
- Switch to usage of schema where possible. This should also simplify the testing.
- Check that all beta flags exist and work.
"container": { | ||
"cpu": { | ||
"usage": { | ||
"corenanoseconds": 3305756719, |
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.
Is this nano seconds? If yes, we should use .ns
: https://www.elastic.co/guide/en/beats/libbeat/5.1/event-conventions.html
"cpu": { | ||
"usage": { | ||
"corenanoseconds": 3305756719, | ||
"nanocores": 5992 |
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.
What is that exactly?
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.
// CPUStats contains data about CPU usage.
type CPUStats struct {
// The time at which these stats were updated.
Time metav1.Time `json:"time"`
// Total CPU usage (sum of all cores) averaged over the sample window.
// The "core" unit can be interpreted as CPU core-nanoseconds per second.
// +optional
UsageNanoCores *uint64 `json:"usageNanoCores,omitempty"`
// Cumulative CPU usage (sum of all cores) since object creation.
// +optional
UsageCoreNanoSeconds *uint64 `json:"usageCoreNanoSeconds,omitempty"`
}
463cf96
to
523a269
Compare
523a269
to
b923485
Compare
jenkins, test it |
@@ -0,0 +1,4 @@ | |||
/* |
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.
[golint] reported by reviewdog 🐶
package comment should be of the form "Package kubelet ..."
@@ -0,0 +1,119 @@ | |||
package kubelet | |||
|
|||
type Summary struct { |
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.
[golint] reported by reviewdog 🐶
exported type Summary should have comment or be unexported
First pass on integrating with kubelet.