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

Metricbeat: MongoDB collstats metricset #5852

Merged
merged 5 commits into from
Jan 8, 2018

Conversation

MerlinDMC
Copy link
Contributor

This adds a metricset for individual collection statistics.
It will allow us to graph "hot" collections for read, write and other spikes in usage.

@elasticmachine
Copy link
Collaborator

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 {

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 {

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)

@MerlinDMC MerlinDMC force-pushed the mongodb-collstats branch 4 times, most recently from 20970b0 to 36a04c4 Compare December 10, 2017 12:14
@MerlinDMC
Copy link
Contributor Author

@ruflin There you go. Happy reviewing 🎉

Copy link
Contributor

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

Left a few comments. Can you please also add a CHANGELOG entry?

description: >
Total number of lock wait events.

- name: readLock.time
Copy link
Contributor

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)
Copy link
Contributor

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))
Copy link
Contributor

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)))
Copy link
Contributor

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],
Copy link
Contributor

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

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.

Copy link
Member

@andrewkroh andrewkroh left a 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.
Copy link
Member

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.

@andrewkroh
Copy link
Member

jenkins, test it

@MerlinDMC
Copy link
Contributor Author

Sorry it took a while longer to get back to this.
I've changed the field naming a little further to include the microseconds hint as well.

@andrewkroh I would not rename it into top - I think it's easier to have a name of what you can expect as an output. Where here it will give you back collection level statistics.
If you want me to rename it so tell me and I will but this at least in my mind is easier to handle.

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

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?

@andrewkroh
Copy link
Member

jenkins, test it

@ruflin ruflin added the module label Jan 4, 2018
@ruflin
Copy link
Contributor

ruflin commented Jan 4, 2018

@MerlinDMC Any chance you could rebase this on master. We made some fixes for CI today.

@MerlinDMC
Copy link
Contributor Author

@ruflin rebase done

@ruflin
Copy link
Contributor

ruflin commented Jan 5, 2018

jenkins, test it

@MerlinDMC
Copy link
Contributor Author

I've rebased again to resolve a merge conflict in the CHANGELOG.asciidoc file.

@MerlinDMC
Copy link
Contributor Author

Looks like the master changes also fixed the CI runs 😄

@exekias exekias merged commit 1821662 into elastic:master Jan 8, 2018
@MerlinDMC MerlinDMC deleted the mongodb-collstats branch January 8, 2018 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants