Skip to content

Commit

Permalink
Add uptime_ns field to mongodb input (influxdata#6669)
Browse files Browse the repository at this point in the history
  • Loading branch information
pertu authored and danielnelson committed Dec 2, 2019
1 parent a803224 commit 7a2db84
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/inputs/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ by running Telegraf with the `--debug` argument.
- flushes (integer)
- flushes_total_time_ns (integer)
- getmores (integer)
- inserts (integer
- inserts (integer)
- jumbo_chunks (integer)
- member_status (string)
- net_in_bytes_count (integer)
Expand Down Expand Up @@ -102,6 +102,7 @@ by running Telegraf with the `--debug` argument.
- ttl_deletes (integer)
- ttl_passes (integer)
- updates (integer)
- uptime_ns (integer)
- vsize_megabytes (integer)
- wtcache_app_threads_page_read_count (integer)
- wtcache_app_threads_page_read_time (integer)
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/mongodb/mongodb_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func NewMongodbData(statLine *StatLine, tags map[string]string) *MongodbData {
}

var DefaultStats = map[string]string{
"uptime_ns": "UptimeNanos",
"inserts": "InsertCnt",
"inserts_per_sec": "Insert",
"queries": "QueryCnt",
Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/mongodb/mongodb_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestAddNonReplStats(t *testing.T) {
&StatLine{
StorageEngine: "",
Time: time.Now(),
UptimeNanos: 0,
Insert: 0,
Query: 0,
Update: 0,
Expand Down Expand Up @@ -235,6 +236,7 @@ func TestStateTag(t *testing.T) {
"resident_megabytes": int64(0),
"updates": int64(0),
"updates_per_sec": int64(0),
"uptime_ns": int64(0),
"vsize_megabytes": int64(0),
"ttl_deletes": int64(0),
"ttl_deletes_per_sec": int64(0),
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/mongodb/mongostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ type StatLine struct {
IsMongos bool
Host string

UptimeNanos int64

// The time at which this StatLine was generated.
Time time.Time

Expand Down Expand Up @@ -659,6 +661,8 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
Faults: -1,
}

returnVal.UptimeNanos = 1000 * 1000 * newStat.UptimeMillis

// set connection info
returnVal.CurrentC = newStat.Connections.Current
returnVal.AvailableC = newStat.Connections.Available
Expand Down

0 comments on commit 7a2db84

Please sign in to comment.