-
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: MongoDB collstats metricset #5852
Conversation
Can one of the admins verify this patch? |
if _, ok := result["totals"]; !ok { | ||
logp.Err("Error accessing collection totals in returned data") | ||
return events, err | ||
} else { |
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.
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
if _, ok := result["totals"]; !ok { | ||
logp.Err("Error accessing collection totals in returned data") | ||
return events, err | ||
} else { |
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.
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
20970b0
to
36a04c4
Compare
@ruflin There you go. Happy reviewing 🎉 |
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.
Left a few comments. Can you please also add a CHANGELOG entry?
description: > | ||
Total number of lock wait events. | ||
|
||
- name: readLock.time |
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 better follow our naming conventions, this should be lock.read.time
, lock.read.count
, lock.write.time
, ....
https://www.elastic.co/guide/en/beats/devguide/current/event-conventions.html
return events, err | ||
} | ||
|
||
totals := result["totals"].(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.
We should check there that this type assertion works by checking for the second return value: totals, ok := result["totals"].(common.MapStr)
...
continue | ||
} | ||
|
||
debugf("input=%v", info.(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.
Was this mainly intended for development? Still needed? If yes, probably add some more text what this debug message is about.
|
||
debugf("input=%v", info.(common.MapStr)) | ||
|
||
events = append(events, eventMapping(group, info.(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.
One more type assertion we should check to guarantee we don't have a panic.
names := strings.SplitN(key, ".", 2) | ||
|
||
event := common.MapStr{ | ||
"db": names[0], |
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.
Let make sure the len of names
is actually at least 0 so 0
and 1
exist.
"db": names[0], | ||
"collection": names[1], | ||
"name": key, | ||
"statistics": 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.
Do we need here the statistics
namespace? As this is already under mongodb.collstats
I think we can put all the stats below directly on the same level.
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 this metricset be called top
? It looks like it uses the [top[(https://docs.mongodb.com/manual/reference/command/top/) command.
Based on ruflin's comments this needs a few field renames.
@@ -0,0 +1 @@ | |||
This is the `collstats` metricset of the module mongodb. |
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.
Could you add a bit of information about what information or commands that it uses to collect the data from mongodb. This might help someone familiar with mongodb to quickly understand what the metricset does.
jenkins, test it |
36a04c4
to
93b3fa7
Compare
Sorry it took a while longer to get back to this. @andrewkroh I would not rename it into |
@@ -0,0 +1,13 @@ | |||
This is the `collstats` metricset of the module mongodb. | |||
|
|||
It is using the `top` adminitrative command to return usage statistics for each collection. It provides the amount of time, in microseconds, used and acount of operations for the following types: |
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.
Thanks, I think this will be helpful.
"acount" looks like a typo. Can you fix that?
93b3fa7
to
317a525
Compare
jenkins, test it |
@MerlinDMC Any chance you could rebase this on master. We made some fixes for CI today. |
317a525
to
30eabfa
Compare
@ruflin rebase done |
jenkins, test it |
30eabfa
to
a19022e
Compare
I've rebased again to resolve a merge conflict in the |
Looks like the master changes also fixed the CI runs 😄 |
This adds a metricset for individual collection statistics.
It will allow us to graph "hot" collections for read, write and other spikes in usage.