Skip to content

Commit

Permalink
Fix MongoDB dbstats fields mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
exekias committed Apr 20, 2017
1 parent 3476405 commit 6b0b077
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
- Make system process metricset honor the cpu_ticks config option. {issue}3590[3590]
- Support common.Time in mapstriface.toTime() {pull}3812[3812]
- Fixing panic on prometheus collector when label has , {pull}3947[3947]
- Fix MongoDB dbstats fields mapping. {pull}4025[4025]

*Packetbeat*

*Winlogbeat*
Expand Down
18 changes: 14 additions & 4 deletions metricbeat/module/mongodb/dbstats/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@
},
"mongodb": {
"dbstats": {
"avg_obj_size": 59,
"avg_obj_size": {
"bytes": 59
},
"collections": 1,
"data_size": 59,
"data_size": {
"bytes": 59
},
"db": "admin",
"index_size": 32768,
"file_size": {},
"index_size": {
"bytes": 32768
},
"indexes": 2,
"ns_size_mb": {},
"num_extents": 0,
"objects": 1,
"storage_size": 16384
"storage_size": {
"bytes": 16384
}
}
},
"type": "metricsets"
Expand Down
40 changes: 27 additions & 13 deletions metricbeat/module/mongodb/dbstats/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,41 @@ import (
)

var schema = s.Schema{
"db": c.Str("db"),
"collections": c.Int("collections"),
"objects": c.Int("objects"),
"avg_obj_size": c.Int("avgObjSize"),
"data_size": c.Int("dataSize"),
"storage_size": c.Int("storageSize"),
"num_extents": c.Int("numExtents"),
"indexes": c.Int("indexes"),
"index_size": c.Int("indexSize"),
"db": c.Str("db"),
"collections": c.Int("collections"),
"objects": c.Int("objects"),
"avg_obj_size": s.Object{
"bytes": c.Int("avgObjSize"),
},
"data_size": s.Object{
"bytes": c.Int("dataSize"),
},
"storage_size": s.Object{
"bytes": c.Int("storageSize"),
},
"num_extents": c.Int("numExtents"),
"indexes": c.Int("indexes"),
"index_size": s.Object{
"bytes": c.Int("indexSize"),
},
// mmapv1 only
"ns_size_mb": c.Int("nsSizeMB", s.Optional),
"ns_size_mb": s.Object{
"mb": c.Int("nsSizeMB", s.Optional),
},
// mmapv1 only
"file_size": c.Int("fileSize", s.Optional),
"file_size": s.Object{
"bytes": c.Int("fileSize", s.Optional),
},
// mmapv1 only
"data_file_version": c.Dict("dataFileVersion", s.Schema{
"major": c.Int("major"),
"minor": c.Int("minor"),
}, c.DictOptional),
// mmapv1 only
"extent_free_list": c.Dict("extentFreeList", s.Schema{
"num": c.Int("num"),
"size": c.Int("size"),
"num": c.Int("num"),
"size": s.Object{
"bytes": c.Int("size", s.Optional),
},
}, c.DictOptional),
}
20 changes: 12 additions & 8 deletions metricbeat/module/mongodb/dbstats/dbstats_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,27 @@ func TestFetch(t *testing.T) {
objects := event["objects"].(int64)
assert.True(t, objects > 0)

avgObjSize := event["avg_obj_size"].(int64)
assert.True(t, avgObjSize > 0)
avgObjSize, err := event.GetValue("avg_obj_size.bytes")
assert.NoError(t, err)
assert.True(t, avgObjSize.(int64) > 0)

dataSize := event["data_size"].(int64)
assert.True(t, dataSize > 0)
dataSize, err := event.GetValue("data_size.bytes")
assert.NoError(t, err)
assert.True(t, dataSize.(int64) > 0)

storageSize := event["storage_size"].(int64)
assert.True(t, storageSize > 0)
storageSize, err := event.GetValue("storage_size.bytes")
assert.NoError(t, err)
assert.True(t, storageSize.(int64) > 0)

numExtents := event["num_extents"].(int64)
assert.True(t, numExtents >= 0)

indexes := event["indexes"].(int64)
assert.True(t, indexes >= 0)

indexSize := event["index_size"].(int64)
assert.True(t, indexSize > 0)
indexSize, err := event.GetValue("index_size.bytes")
assert.NoError(t, err)
assert.True(t, indexSize.(int64) > 0)
}
}

Expand Down
8 changes: 0 additions & 8 deletions metricbeat/module/mongodb/status/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,3 @@
type: long
description: >
Number of sync operations.

0 comments on commit 6b0b077

Please sign in to comment.