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

Kubernetes module for metricbeat #3916

Merged
merged 2 commits into from
Apr 10, 2017
Merged

Conversation

vjsamuel
Copy link
Contributor

@vjsamuel vjsamuel commented Apr 5, 2017

First pass on integrating with kubelet.

@elasticmachine
Copy link
Collaborator

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
@elasticmachine
Copy link
Collaborator

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.

@ruflin ruflin added in progress Pull request is currently in progress. Metricbeat Metricbeat module review labels Apr 5, 2017
@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably these are spurious :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@vjsamuel vjsamuel force-pushed the kubernetes_module branch 2 times, most recently from 63ca4f9 to 8a7933a Compare April 6, 2017 04:57
Copy link
Member

@ruflin ruflin left a 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.

metricsets: ["node","container","volume","pod","system"]
enabled: true
period: 10s
hosts: ["localhost"]
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -179,6 +179,14 @@ metricbeat.modules:
#username: ""
#password: ""

#------------------------------- kubelet Module ------------------------------
- module: kubelet
Copy link
Member

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.

@@ -46,6 +46,14 @@ metricbeat.modules:
period: 10s
processes: ['.*']

#------------------------------- kubelet Module ------------------------------
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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 :-)

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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,
Copy link
Member

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 ...

Copy link
Contributor Author

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{
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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,
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vjsamuel vjsamuel force-pushed the kubernetes_module branch 2 times, most recently from 4f27f0a to 463cf96 Compare April 6, 2017 22:07
Copy link
Member

@ruflin ruflin left a 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,
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruflin

// 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"`
}

@andrewkroh
Copy link
Member

jenkins, test it

@@ -0,0 +1,4 @@
/*
Copy link
Collaborator

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 {
Copy link
Collaborator

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

@exekias exekias merged commit 7dadfe7 into elastic:master Apr 10, 2017
@exekias exekias removed in progress Pull request is currently in progress. review labels Apr 10, 2017
@exekias exekias mentioned this pull request Apr 10, 2017
8 tasks
@vjsamuel vjsamuel deleted the kubernetes_module branch April 10, 2017 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants