From 55b798bd20c28ea1af8d0f3ef2ee980048e6cbc2 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Wed, 28 Nov 2018 16:43:13 -0800 Subject: [PATCH] Fix mongodb document stats (#5049) --- plugins/inputs/mongodb/README.md | 7 +++++++ plugins/inputs/mongodb/mongostat.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/plugins/inputs/mongodb/README.md b/plugins/inputs/mongodb/README.md index 96852d724..105584462 100644 --- a/plugins/inputs/mongodb/README.md +++ b/plugins/inputs/mongodb/README.md @@ -48,11 +48,18 @@ Error in input [mongodb]: not authorized on admin to execute command { serverSta - active_reads (integer) - active_writes (integer) - commands_per_sec (integer) + - connections_current (integer) + - connections_available (integer) + - connections_total_created (integer) - cursor_timed_out (integer) - cursor_no_timeout (integer) - cursor_pinned (integer) - cursor_total (integer) - deletes_per_sec (integer) + - document_deleted (integer) + - document_inserted (integer) + - document_returned (integer) + - document_updated (integer) - flushes_per_sec (integer) - getmores_per_sec (integer) - inserts_per_sec (integer) diff --git a/plugins/inputs/mongodb/mongostat.go b/plugins/inputs/mongodb/mongostat.go index 1acda5826..e32596deb 100644 --- a/plugins/inputs/mongodb/mongostat.go +++ b/plugins/inputs/mongodb/mongostat.go @@ -633,6 +633,12 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec returnVal.TotalC = diff(newStat.Metrics.Cursor.Open.Total, oldStat.Metrics.Cursor.Open.Total, sampleSecs) } } + if newStat.Metrics.Document != nil { + returnVal.DeletedD = newStat.Metrics.Document.Deleted + returnVal.InsertedD = newStat.Metrics.Document.Inserted + returnVal.ReturnedD = newStat.Metrics.Document.Returned + returnVal.UpdatedD = newStat.Metrics.Document.Updated + } } if newStat.OpcountersRepl != nil && oldStat.OpcountersRepl != nil {