Skip to content

Commit

Permalink
Update variable names and readme to new style
Browse files Browse the repository at this point in the history
  • Loading branch information
grubernaut authored and Jake Champlin committed Apr 10, 2018
1 parent f36cfa2 commit 36ef4f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 51 deletions.
57 changes: 10 additions & 47 deletions plugins/inputs/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Error in input [mongodb]: not authorized on admin to execute command { serverSta
- repl_lag (integer)
- repl_queries_per_sec (integer)
- repl_updates_per_sec (integer)
- repl_oplog_window_sec (integer)
- resident_megabytes (integer)
- state (string)
- total_available (integer)
Expand All @@ -92,35 +93,6 @@ Error in input [mongodb]: not authorized on admin to execute command { serverSta
- wtcache_tracked_dirty_bytes (integer)
- wtcache_worker_thread_evictingpages (integer)

The telegraf plugin collects mongodb stats exposed by serverStatus and few more
and create a single measurement containing values e.g.
* active_reads
* active_writes
* commands_per_sec
* deletes_per_sec
* flushes_per_sec
* getmores_per_sec
* inserts_per_sec
* net_in_bytes
* net_out_bytes
* open_connections
* percent_cache_dirty
* percent_cache_used
* queries_per_sec
* queued_reads
* queued_writes
* resident_megabytes
* updates_per_sec
* vsize_megabytes
* total_in_use
* total_available
* total_created
* total_refreshing
* ttl_deletes_per_sec
* ttl_passes_per_sec
* repl_lag
* repl_oplog_window_s
* jumbo_chunks (only if mongos or mongo config)
- mongodb_db_stats
- tags:
- db_name
Expand All @@ -137,27 +109,18 @@ and create a single measurement containing values e.g.
- storage_size (integer)
- type (string)

If gather_db_stats is set to true, it will also collect per database stats exposed by db.stats()
creating another measurement called mongodb_db_stats and containing values:
* collections
* objects
* avg_obj_size
* data_size
* storage_size
* num_extents
* indexes
* index_size
* ok

If multiple shard hosts are found via the `shardConnPoolStats` command, it will also collect per-host shard stats exposed
by `shardConnPoolStats` creating another measurement called `mongodb_shard_host_stats`, containing the following values:
* in_use
* available
* created
* refreshing
- mongodb_shard_stats
- tags:
- hostname
- fields:
- in_use (integer)
- available (integer)
- created (integer)
- refreshing (integer)

### Example Output:
```
mongodb,hostname=127.0.0.1:27017 active_reads=0i,active_writes=0i,commands_per_sec=6i,deletes_per_sec=0i,flushes_per_sec=0i,getmores_per_sec=1i,inserts_per_sec=0i,jumbo_chunks=0i,member_status="PRI",net_in_bytes=851i,net_out_bytes=23904i,open_connections=6i,percent_cache_dirty=0,percent_cache_used=0,queries_per_sec=2i,queued_reads=0i,queued_writes=0i,repl_commands_per_sec=0i,repl_deletes_per_sec=0i,repl_getmores_per_sec=0i,repl_inserts_per_sec=0i,repl_lag=0i,repl_queries_per_sec=0i,repl_updates_per_sec=0i,resident_megabytes=67i,state="PRIMARY",total_available=0i,total_created=0i,total_in_use=0i,total_refreshing=0i,ttl_deletes_per_sec=0i,ttl_passes_per_sec=0i,updates_per_sec=0i,vsize_megabytes=729i,wtcache_app_threads_page_read_count=4i,wtcache_app_threads_page_read_time=18i,wtcache_app_threads_page_write_count=6i,wtcache_bytes_read_into=10075i,wtcache_bytes_written_from=115711i,wtcache_current_bytes=86038i,wtcache_max_bytes_configured=1073741824i,wtcache_pages_evicted_by_app_thread=0i,wtcache_pages_queued_for_eviction=0i,wtcache_server_evicting_pages=0i,wtcache_tracked_dirty_bytes=0i,wtcache_worker_thread_evictingpages=0i 1522798796000000000
mongodb_db_stats,db_name=local,hostname=127.0.0.1:27017 avg_obj_size=818.625,collections=5i,data_size=6549i,index_size=86016i,indexes=4i,num_extents=0i,objects=8i,ok=1i,storage_size=118784i,type="db_stat" 1522799074000000000
mongodb_shard_stats,hostname=127.0.0.1:27017,in_use=3i,available=3i,created=4i,refreshing=0i 1522799074000000000
```
4 changes: 2 additions & 2 deletions plugins/inputs/mongodb/mongodb_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ func (d *MongodbData) flush(acc telegraf.Accumulator) {
db.Fields = make(map[string]interface{})
}
for _, host := range d.ShardHostData {
d.Tags["shard_host_name"] = host.Name
d.Tags["hostname"] = host.Name
acc.AddFields(
"mongodb_shard_host_stats",
"mongodb_shard_stats",
host.Fields,
d.Tags,
d.StatLine.Time,
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/mongodb/mongodb_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ func TestAddShardHostStats(t *testing.T) {
var hostsFound []string
for host, _ := range hostStatLines {
for key, _ := range ShardHostStats {
assert.True(t, acc.HasInt64Field("mongodb_shard_host_stats", key))
assert.True(t, acc.HasInt64Field("mongodb_shard_stats", key))
}

assert.True(t, acc.HasTag("mongodb_shard_host_stats", "shard_host_name"))
assert.True(t, acc.HasTag("mongodb_shard_stats", "hostname"))
hostsFound = append(hostsFound, host)
}

Expand Down

0 comments on commit 36ef4f8

Please sign in to comment.