fix: filter out views in mongodb lookup (#11280)
This commit is contained in:
parent
748290d5d0
commit
42a167ffde
|
|
@ -3,13 +3,13 @@ package mongodb
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"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"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||||
|
|
@ -229,8 +229,11 @@ func (s *Server) gatherCollectionStats(colStatsDbs []string) (*ColStats, error)
|
||||||
results := &ColStats{}
|
results := &ColStats{}
|
||||||
for _, dbName := range names {
|
for _, dbName := range names {
|
||||||
if stringInSlice(dbName, colStatsDbs) || len(colStatsDbs) == 0 {
|
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
|
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 {
|
if err != nil {
|
||||||
s.Log.Errorf("Error getting collection names: %s", err.Error())
|
s.Log.Errorf("Error getting collection names: %s", err.Error())
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue