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:
|
- tags:
|
||||||
- hostname
|
- hostname
|
||||||
- node_type
|
- node_type
|
||||||
|
- rs_name
|
||||||
- fields:
|
- fields:
|
||||||
- active_reads (integer)
|
- active_reads (integer)
|
||||||
- active_writes (integer)
|
- active_writes (integer)
|
||||||
|
|
|
@ -245,6 +245,10 @@ func (d *MongodbData) AddDefaultStats() {
|
||||||
d.addStat(statLine, DefaultLatencyStats)
|
d.addStat(statLine, DefaultLatencyStats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.StatLine.ReplSetName != "" {
|
||||||
|
d.Tags["rs_name"] = d.StatLine.ReplSetName
|
||||||
|
}
|
||||||
|
|
||||||
if d.StatLine.OplogStats != nil {
|
if d.StatLine.OplogStats != nil {
|
||||||
d.add("repl_oplog_window_sec", d.StatLine.OplogStats.TimeDiff)
|
d.add("repl_oplog_window_sec", d.StatLine.OplogStats.TimeDiff)
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,12 +211,14 @@ func TestStateTag(t *testing.T) {
|
||||||
Query: 0,
|
Query: 0,
|
||||||
NodeType: "PRI",
|
NodeType: "PRI",
|
||||||
NodeState: "PRIMARY",
|
NodeState: "PRIMARY",
|
||||||
|
ReplSetName: "rs1",
|
||||||
},
|
},
|
||||||
tags,
|
tags,
|
||||||
)
|
)
|
||||||
|
|
||||||
stateTags := make(map[string]string)
|
stateTags := make(map[string]string)
|
||||||
stateTags["node_type"] = "PRI"
|
stateTags["node_type"] = "PRI"
|
||||||
|
stateTags["rs_name"] = "rs1"
|
||||||
|
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue