Add replica set tag to mongodb input (#6914)
This commit is contained in:
parent
5d9cecaa02
commit
cb50fadc20
|
@ -56,6 +56,7 @@ by running Telegraf with the `--debug` argument.
|
|||
- tags:
|
||||
- hostname
|
||||
- node_type
|
||||
- rs_name
|
||||
- fields:
|
||||
- active_reads (integer)
|
||||
- active_writes (integer)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue