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

Add more MongoDB metrics #5273

Merged
merged 3 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/inputs/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Error in input [mongodb]: not authorized on admin to execute command { serverSta
- document_returned (integer)
- document_updated (integer)
- flushes (integer)
- flushes_total_time_ns (integer)
- getmores (integer)
- inserts (integer
- jumbo_chunks (integer)
Expand Down Expand Up @@ -96,8 +97,13 @@ Error in input [mongodb]: not authorized on admin to execute command { serverSta
- wtcache_app_threads_page_write_count (integer)
- wtcache_bytes_read_into (integer)
- wtcache_bytes_written_from (integer)
- wtcache_pages_read_info (integer)
- wtcache_pages_requested_from (integer)
- wtcache_current_bytes (integer)
- wtcache_max_bytes_configured (integer)
- wtcache_internal_pages_evicted (integer)
- wtcache_modified_pages_evicted (integer)
- wtcache_unmodified_pages_evicted (integer)
- wtcache_pages_evicted_by_app_thread (integer)
- wtcache_pages_queued_for_eviction (integer)
- wtcache_server_evicting_pages (integer)
Expand Down
6 changes: 6 additions & 0 deletions plugins/inputs/mongodb/mongodb_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var DefaultStats = map[string]string{
"commands_per_sec": "Command",
"flushes": "FlushesCnt",
"flushes_per_sec": "Flushes",
"flushes_total_time_ns": "FlushesTotalTime",
"vsize_megabytes": "Virtual",
"resident_megabytes": "Resident",
"queued_reads": "QueuedReaders",
Expand Down Expand Up @@ -137,8 +138,13 @@ var WiredTigerExtStats = map[string]string{
"wtcache_bytes_read_into": "BytesReadInto",
"wtcache_pages_evicted_by_app_thread": "PagesEvictedByAppThread",
"wtcache_pages_queued_for_eviction": "PagesQueuedForEviction",
"wtcache_pages_read_info": "PagesReadIntoCache",
"wtcache_pages_requested_from": "PagesRequestedFromCache",
"wtcache_server_evicting_pages": "ServerEvictingPages",
"wtcache_worker_thread_evictingpages": "WorkerThreadEvictingPages",
"wtcache_internal_pages_evicted": "InternalPagesEvicted",
"wtcache_modified_pages_evicted": "ModifiedPagesEvicted",
"wtcache_unmodified_pages_evicted": "UnmodifiedPagesEvicted",
}

var DbDataStats = map[string]string{
Expand Down
11 changes: 8 additions & 3 deletions plugins/inputs/mongodb/mongodb_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestAddNonReplStats(t *testing.T) {
d.flush(&acc)

for key := range DefaultStats {
assert.True(t, acc.HasInt64Field("mongodb", key))
assert.True(t, acc.HasFloatField("mongodb", key) || acc.HasInt64Field("mongodb", key), key)
}
}

Expand All @@ -77,7 +77,7 @@ func TestAddReplStats(t *testing.T) {
d.flush(&acc)

for key := range MmapStats {
assert.True(t, acc.HasInt64Field("mongodb", key))
assert.True(t, acc.HasInt64Field("mongodb", key), key)
}
}

Expand Down Expand Up @@ -109,7 +109,11 @@ func TestAddWiredTigerStats(t *testing.T) {
d.flush(&acc)

for key := range WiredTigerStats {
assert.True(t, acc.HasFloatField("mongodb", key))
assert.True(t, acc.HasFloatField("mongodb", key), key)
}

for key := range WiredTigerExtStats {
assert.True(t, acc.HasFloatField("mongodb", key) || acc.HasInt64Field("mongodb", key), key)
}
}

Expand Down Expand Up @@ -199,6 +203,7 @@ func TestStateTag(t *testing.T) {
"deletes_per_sec": int64(0),
"flushes": int64(0),
"flushes_per_sec": int64(0),
"flushes_total_time_ns": int64(0),
"getmores": int64(0),
"getmores_per_sec": int64(0),
"inserts": int64(0),
Expand Down
28 changes: 25 additions & 3 deletions plugins/inputs/mongodb/mongostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,19 @@ type CacheStats struct {
BytesReadInto int64 `bson:"bytes read into cache"`
PagesEvictedByAppThread int64 `bson:"pages evicted by application threads"`
PagesQueuedForEviction int64 `bson:"pages queued for eviction"`
PagesReadIntoCache int64 `bson:"pages read into cache"`
PagesRequestedFromCache int64 `bson:"pages requested from the cache"`
ServerEvictingPages int64 `bson:"eviction server evicting pages"`
WorkerThreadEvictingPages int64 `bson:"eviction worker thread evicting pages"`
InternalPagesEvicted int64 `bson:"internal pages evicted"`
ModifiedPagesEvicted int64 `bson:"modified pages evicted"`
UnmodifiedPagesEvicted int64 `bson:"unmodified pages evicted"`
}

// TransactionStats stores transaction checkpoints in WiredTiger.
type TransactionStats struct {
TransCheckpoints int64 `bson:"transaction checkpoints"`
TransCheckpointsTotalTimeMsecs int64 `bson:"transaction checkpoint total time (msecs)"`
TransCheckpoints int64 `bson:"transaction checkpoints"`
}

// ReplStatus stores data related to replica sets.
Expand Down Expand Up @@ -498,8 +504,13 @@ type StatLine struct {
BytesReadInto int64
PagesEvictedByAppThread int64
PagesQueuedForEviction int64
PagesReadIntoCache int64
PagesRequestedFromCache int64
ServerEvictingPages int64
WorkerThreadEvictingPages int64
InternalPagesEvicted int64
ModifiedPagesEvicted int64
UnmodifiedPagesEvicted int64

// Replicated Opcounter fields
InsertR, InsertRCnt int64
Expand All @@ -511,6 +522,7 @@ type StatLine struct {
ReplLag int64
OplogTimeDiff int64
Flushes, FlushesCnt int64
FlushesTotalTime int64
Mapped, Virtual, Resident, NonMapped int64
Faults, FaultsCnt int64
HighestLocked *LockStatus
Expand Down Expand Up @@ -666,8 +678,7 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec

returnVal.CacheDirtyPercent = -1
returnVal.CacheUsedPercent = -1
if newStat.WiredTiger != nil && oldStat.WiredTiger != nil {
returnVal.Flushes, returnVal.FlushesCnt = diff(newStat.WiredTiger.Transaction.TransCheckpoints, oldStat.WiredTiger.Transaction.TransCheckpoints, sampleSecs)
if newStat.WiredTiger != nil {
returnVal.CacheDirtyPercent = float64(newStat.WiredTiger.Cache.TrackedDirtyBytes) / float64(newStat.WiredTiger.Cache.MaxBytesConfigured)
returnVal.CacheUsedPercent = float64(newStat.WiredTiger.Cache.CurrentCachedBytes) / float64(newStat.WiredTiger.Cache.MaxBytesConfigured)

Expand All @@ -681,8 +692,19 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
returnVal.BytesReadInto = newStat.WiredTiger.Cache.BytesReadInto
returnVal.PagesEvictedByAppThread = newStat.WiredTiger.Cache.PagesEvictedByAppThread
returnVal.PagesQueuedForEviction = newStat.WiredTiger.Cache.PagesQueuedForEviction
returnVal.PagesReadIntoCache = newStat.WiredTiger.Cache.PagesReadIntoCache
returnVal.PagesRequestedFromCache = newStat.WiredTiger.Cache.PagesRequestedFromCache
returnVal.ServerEvictingPages = newStat.WiredTiger.Cache.ServerEvictingPages
returnVal.WorkerThreadEvictingPages = newStat.WiredTiger.Cache.WorkerThreadEvictingPages

returnVal.InternalPagesEvicted = newStat.WiredTiger.Cache.InternalPagesEvicted
returnVal.ModifiedPagesEvicted = newStat.WiredTiger.Cache.ModifiedPagesEvicted
returnVal.UnmodifiedPagesEvicted = newStat.WiredTiger.Cache.UnmodifiedPagesEvicted

returnVal.FlushesTotalTime = newStat.WiredTiger.Transaction.TransCheckpointsTotalTimeMsecs * int64(time.Millisecond)
}
if newStat.WiredTiger != nil && oldStat.WiredTiger != nil {
returnVal.Flushes, returnVal.FlushesCnt = diff(newStat.WiredTiger.Transaction.TransCheckpoints, oldStat.WiredTiger.Transaction.TransCheckpoints, sampleSecs)
} else if newStat.BackgroundFlushing != nil && oldStat.BackgroundFlushing != nil {
returnVal.Flushes, returnVal.FlushesCnt = diff(newStat.BackgroundFlushing.Flushes, oldStat.BackgroundFlushing.Flushes, sampleSecs)
}
Expand Down