-
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
Add Kubernetes StatefulSet metricset #6236
Conversation
Conflicts: metricbeat/docs/modules_list.asciidoc
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
@@ -0,0 +1,111 @@ | |||
// +build !integration | |||
|
|||
package state_statefulset |
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.
don't use an underscore in package name
@@ -0,0 +1,62 @@ | |||
package state_statefulset |
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.
don't use an underscore in package name
continue | ||
} | ||
namespace := util.GetLabel(metric, "namespace") | ||
statefulset_key := namespace + "::" + statefulset |
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.
don't use underscores in Go names; var statefulset_key should be statefulsetKey
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 the bot comment is valid here 😇
Now I see this, it seems the rest of state_*
may miss the namespacing you did here, I'm glad you found 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 was going to mention it after this pull request. Worth fixing others no doubt. :)
@@ -0,0 +1,52 @@ | |||
package state_statefulset |
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.
don't use an underscore in package name
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.
Following same pattern as other classes.
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, please ignore the bot on this.
Added unit testing for StatefulSet support. Made StatefulSet be relative to namespace (i.e. you can have two statefulsets with same name belonging to different namespaces). |
I signed CLA already. |
@fassisrosa Thanks for you contribution. Haven't look at the code yet but it for sure will need an entry in the CHANGELOG :-) |
Added entry to CHANGELOG. |
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 contribution, thank you @fassisrosa 🎉, StatefulSets are a great addition! I left some minor comments 😄
continue | ||
} | ||
namespace := util.GetLabel(metric, "namespace") | ||
statefulset_key := namespace + "::" + statefulset |
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 the bot comment is valid here 😇
Now I see this, it seems the rest of state_*
may miss the namespacing you did here, I'm glad you found this!
// Part of new is also setting up the configuration by processing additional | ||
// configuration entries if needed. | ||
func New(base mb.BaseMetricSet) (mb.MetricSet, error) { | ||
cfgwarn.Beta("The kubernetes state_statefulset metricset is beta") |
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 remove this message, kubernetes module has been promoted to GA
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.
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.
Fixed bot comment.
jenkins, test it please |
} | ||
|
||
if len(testCases) > 0 { | ||
t.Error("Test reference events not found: %v", testCases) |
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 should be Errorf
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.
} | ||
} | ||
|
||
var events []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.
Maybe you could pre allocate events by events := make([]common.MapStr, 0, len(eventsMap))
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.
Any idea what this Travis CI build fail is all about? Looks like a code convention violation but have no idea about the test’s expectations... |
@fassisrosa You should obey the the go import style. First section with std pkgs, second is community pkgs such as github.com, third section is project pkg in this case is pkg under beats project. |
Understood, I think... but then how did state_replicaset_test.go pass checks? Tried to follow same convention. Just to confirm, issue is in state_statefulset_test.go imports should be in correct order:
Is this the correct fix? Thanks for your patience, this is my first commit to beats, trying to understand the rules for submissions :) |
That looks correct, you can use |
Thanks @exekias , made changes, ran fmt, pushed. |
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.
Waiting for green
ok to test |
func New(base mb.BaseMetricSet) (mb.MetricSet, error) { | ||
return &MetricSet{ | ||
BaseMetricSet: base, | ||
prometheus: helper.NewPrometheusClient(base), |
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 line is failing in the CI, NewPrometheusClient
can return an 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.
To put some context, this changed very recently: #6205, probably your working copy doesn't have the change
Thank you so much for this great addition @fassisrosa 🎉!! |
Thanks so much for the review comments. Love metricbeat, using it all the time! :) |
I've opened #6281 to fix the namespacing issue in the rest of |
Taking a stab at it... Pull request above. :) |
Added support for Kubernetes StatefulSet.