Add replica set tag to mongodb input (#6914)

This commit is contained in:
AnastasiyaRagozina 2020-01-24 02:46:23 +03:00 committed by Daniel Nelson
parent 5d9cecaa02
commit cb50fadc20
3 changed files with 7 additions and 0 deletions

View File

@ -56,6 +56,7 @@ by running Telegraf with the `--debug` argument.
- tags:
- hostname
- node_type
- rs_name
- fields:
- active_reads (integer)
- active_writes (integer)

View File

@ -245,6 +245,10 @@ func (d *MongodbData) AddDefaultStats() {
d.addStat(statLine, DefaultLatencyStats)
}
if d.StatLine.ReplSetName != "" {
d.Tags["rs_name"] = d.StatLine.ReplSetName
}
if d.StatLine.OplogStats != nil {
d.add("repl_oplog_window_sec", d.StatLine.OplogStats.TimeDiff)
}

View File

@ -211,12 +211,14 @@ func TestStateTag(t *testing.T) {
Query: 0,
NodeType: "PRI",
NodeState: "PRIMARY",
ReplSetName: "rs1",
},
tags,
)
stateTags := make(map[string]string)
stateTags["node_type"] = "PRI"
stateTags["rs_name"] = "rs1"
var acc testutil.Accumulator