diff --git a/plugins/inputs/mongodb/mongodb.go b/plugins/inputs/mongodb/mongodb.go index 381814531..f38fa31ef 100644 --- a/plugins/inputs/mongodb/mongodb.go +++ b/plugins/inputs/mongodb/mongodb.go @@ -69,10 +69,10 @@ func (m *MongoDB) Gather(acc telegraf.Accumulator) error { } } wg.Add(1) - go func() { + go func(srv *Server) { defer wg.Done() - outerr = m.gatherServer(m.getMongoServer(u), acc) - }() + outerr = m.gatherServer(srv, acc) + }(m.getMongoServer(u)) } wg.Wait()