-
Notifications
You must be signed in to change notification settings - Fork 20
Add -local_only flag to get local node metrics per node #170
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
base: master
Are you sure you want to change the base?
Conversation
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.
mock: Unexpected Method Call
-----------------------------
Request(string)
0: "/_nodes/_local/id"
The closest call I have is:
Request(string)
0: "/_nodes/_local"
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.
need help updating mock
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.
Updated integration tests so that it passes now
| IndicesRegex string `default:"" help:"A regex pattern that matches the index names to collect. Collects all if unspecified"` | ||
| ShowVersion bool `default:"false" help:"Print build information and exit"` | ||
| MasterOnly bool `default:"false" help:"Collect cluster metrics on the elected master only"` | ||
| LocalOnly bool `default:"false" help:"Collect node metrics on the local node only"` |
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 add an integration test?
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.
need help with this
src/metrics.go
Outdated
| } else { | ||
| needed = true | ||
| } | ||
| return |
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.
simply
return true
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.
cleaned up the function logic
src/metrics.go
Outdated
| log.Error("There was an error gathering the elected master node ID: %v", err) | ||
| return | ||
| } | ||
| needed = nodeID == masterID |
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.
Also here I prefer an early
return nodeID == masterID
and maybe without named return values is better
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
src/metrics.go
Outdated
| if args.MasterOnly || args.LocalOnly { | ||
| masterID, err := getMasterNodeID(client) | ||
| if err != nil { | ||
| log.Error("There was an error gathering the elected master node ID: %v", 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.
We should not hide errors, The signature likely should be
func getClusterNeeded(client Client, nodeID string) (bool, Error) {
But then it is again difficult to read 🤔
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.
updated function name
|
Still need to add a test for |
|
Looks like |
|
You can get rid of returntocorp/semgrep-action We did the same here |
This adds a
-local_onlyargument to support collecting local node metrics per node. The OHI would reside on each node, and thus propagates its host tags to the metrics collected. The master node would additionally collect cluster and common metrics with this option.