fix: filter out views in mongodb lookup (#11280)
This commit is contained in:
parent
748290d5d0
commit
42a167ffde
|
|
@ -3,13 +3,13 @@ package mongodb
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||
|
|
@ -229,8 +229,11 @@ func (s *Server) gatherCollectionStats(colStatsDbs []string) (*ColStats, error)
|
|||
results := &ColStats{}
|
||||
for _, dbName := range names {
|
||||
if stringInSlice(dbName, colStatsDbs) || len(colStatsDbs) == 0 {
|
||||
// skip views as they fail on collStats below
|
||||
filter := bson.M{"type": bson.M{"$in": bson.A{"collection", "timeseries"}}}
|
||||
|
||||
var colls []string
|
||||
colls, err = s.client.Database(dbName).ListCollectionNames(context.Background(), bson.D{})
|
||||
colls, err = s.client.Database(dbName).ListCollectionNames(context.Background(), filter)
|
||||
if err != nil {
|
||||
s.Log.Errorf("Error getting collection names: %s", err.Error())
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in New Issue