fix(inputs.mongodb): Do not dereference nil pointer if gathering database stats fails (#16310)

This commit is contained in:
Dmitry Khamitov 2024-12-17 17:09:13 +00:00 committed by GitHub
parent 7360f5dc5a
commit 3b87986f42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -327,7 +327,8 @@ func (s *server) gatherData(acc telegraf.Accumulator, gatherClusterStatus, gathe
for _, name := range names {
db, err := s.gatherDBStats(name)
if err != nil {
s.log.Debugf("Error getting db stats from %q: %s", name, err.Error())
s.log.Errorf("Error getting db stats from %q: %v", name, err)
continue
}
dbStats.Dbs = append(dbStats.Dbs, *db)
}