Skip to content

Commit

Permalink
Metric for MongoDB jumbo chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Garcia committed Apr 29, 2016
1 parent cbe32c7 commit 6554386
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ based on _prefix_ in addition to globs. This means that a filter like
- [#967](https://github.com/influxdata/telegraf/issues/967): Buffer logging improvements.
- [#1107](https://github.com/influxdata/telegraf/issues/1107): Support lustre2 job stats. Thanks @hanleyja!
- [#1122](https://github.com/influxdata/telegraf/pull/1122): Support setting config path through env variable and default paths.
- [#1098](https://github.com/influxdata/telegraf/issues/1098): Sanitize invalid OpenTSDB characters.
- [#1110](https://github.com/influxdata/telegraf/pull/1110): Sanitize * to - in graphite serializer. Thanks @goodeggs!
- [#1118](https://github.com/influxdata/telegraf/pull/1118): Sanitize Counter names for `win_perf_counters` input.
- [#1128](https://github.com/influxdata/telegraf/pull/1128): MongoDB jumbo chunks metric for MongoDB input plugin

### Bugfixes

Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ and create a single measurement containing values e.g.
* ttl_deletes_per_sec
* ttl_passes_per_sec
* repl_lag
* jumbo_chunks (only if mongos or mongo config)
5 changes: 5 additions & 0 deletions plugins/inputs/mongodb/mongodb_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ var DefaultReplStats = map[string]string{
"repl_lag": "ReplLag",
}

var DefaultClusterStats = map[string]string{
"jumbo_chunks": "JumboChunksCount",
}

var MmapStats = map[string]string{
"mapped_megabytes": "Mapped",
"non-mapped_megabytes": "NonMapped",
Expand All @@ -74,6 +78,7 @@ func (d *MongodbData) AddDefaultStats() {
if d.StatLine.NodeType != "" {
d.addStat(statLine, DefaultReplStats)
}
d.addStat(statLine, DefaultClusterStats)
if d.StatLine.StorageEngine == "mmapv1" {
d.addStat(statLine, MmapStats)
} else if d.StatLine.StorageEngine == "wiredTiger" {
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/mongodb/mongodb_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func TestStateTag(t *testing.T) {
"vsize_megabytes": int64(0),
"ttl_deletes_per_sec": int64(0),
"ttl_passes_per_sec": int64(0),
"jumbo_chunks": int64(0),
}
acc.AssertContainsTaggedFields(t, "mongodb", fields, stateTags)
}
10 changes: 10 additions & 0 deletions plugins/inputs/mongodb/mongodb_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ func (s *Server) gatherData(acc telegraf.Accumulator) error {
log.Println("Not gathering replica set status, member not in replica set")
}

jumbo_chunks := 0
jumbo_chunks, err = s.Session.DB("config").C("chunks").Find(bson.M{"jumbo": true}).Count()
if err != nil {
log.Println("Not gathering jumbo chunks metric, this is not a config server or mongos")
}
result_cluster := &ClusterStatus{
JumboChunksCount: int64(jumbo_chunks),
}

result := &MongoStatus{
ServerStatus: result_server,
ReplSetStatus: result_repl,
ClusterStatus: result_cluster,
}

defer func() {
Expand Down
12 changes: 12 additions & 0 deletions plugins/inputs/mongodb/mongostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type MongoStatus struct {
SampleTime time.Time
ServerStatus *ServerStatus
ReplSetStatus *ReplSetStatus
ClusterStatus *ClusterStatus
}

type ServerStatus struct {
Expand Down Expand Up @@ -64,6 +65,11 @@ type ServerStatus struct {
Metrics *MetricsStats `bson:"metrics"`
}

// ClusterStatus stores information related to the whole cluster
type ClusterStatus struct {
JumboChunksCount int64
}

// ReplSetStatus stores information from replSetGetStatus
type ReplSetStatus struct {
Members []ReplSetMember `bson:"members"`
Expand Down Expand Up @@ -387,6 +393,9 @@ type StatLine struct {
NumConnections int64
ReplSetName string
NodeType string

// Cluster fields
JumboChunksCount int64
}

func parseLocks(stat ServerStatus) map[string]LockUsage {
Expand Down Expand Up @@ -665,5 +674,8 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
}
}

newClusterStat := *newMongo.ClusterStatus
returnVal.JumboChunksCount = newClusterStat.JumboChunksCount

return returnVal
}

0 comments on commit 6554386

Please sign in to comment.