dcu / mongodb_exporter

MongoDB exporter for prometheus.io
MIT License
356 stars 216 forks source link

Add profile collector #73

Closed smaftoul closed 7 years ago

smaftoul commented 7 years ago

Add a profiler collector: This PR adds a collector that will, for a given database, count the number of objects in the system.profile collection that have been inserted during the last 30 seconds. The system.profile collection, contains, if mongodb profiler is enabled, slow requests (and might contain other requests but not sure which). Also, by default, this collection is capped to 1MB , so we cannot simply count the total number of documents in the collection, return it as-is, and use rate() to see overtime when we have slow requets.

@dcu are you interested by such a collector / metric ? Do you have idea to improve it, such as , for example, be able to configure the time range for the Find().Count() ? Would this belong to the database collector ? Should I add a (configurable ?) millis criteria to the Find() ?

dcu commented 7 years ago

oh yes this is great @smaftoul very useful

smaftoul commented 7 years ago

Not part of my PR , but your comment on CamelCase and error logging also applies to: https://github.com/dcu/mongodb_exporter/blob/master/collector/mongodb_collector.go#L166-L168 (Which I shamelessly mostly copied ;)). Want me to fix this in this PR ? another one ?

dcu commented 7 years ago

@smaftoul can you use gofmt to format the code? most editors have plugins to do that automatically

smaftoul commented 7 years ago

@dcu go fmt done and PR rebased.