Skip to content

Commit

Permalink
plugins/inputs/nats: Add a nats_server tag
Browse files Browse the repository at this point in the history
Include the NATS server URL as a tag to allow multiple instances of
the nats input plugin to be distinguished.
  • Loading branch information
mjs committed Jan 16, 2018
1 parent 80b4e29 commit 3128c32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion plugins/inputs/nats/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func (n *Nats) Gather(acc telegraf.Accumulator) error {
"slow_consumers": stats.SlowConsumers,
"routes": stats.Routes,
"remotes": stats.Remotes,
}, nil, time.Now())
},
map[string]string{"nats_server": n.Server},
time.Now())

return nil
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/inputs/nats/nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ func TestMetricsCorrect(t *testing.T) {
"routes": int(1),
"remotes": int(2),
}
acc.AssertContainsFields(t, "nats_varz", fields)
tags := map[string]string{
"nats_server": srv.URL,
}
acc.AssertContainsTaggedFields(t, "nats_varz", fields, tags)
}

func newTestNatsServer() *httptest.Server {
Expand Down

0 comments on commit 3128c32

Please sign in to comment.