Skip to content

Commit

Permalink
feat: bcs-monitor支持配置mongodb副本集名称 (#3645)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyudeqiu authored Dec 18, 2024
1 parent 280e182 commit 744f9f4
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 57 deletions.
113 changes: 56 additions & 57 deletions bcs-services/bcs-monitor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ module github.com/Tencent/bk-bcs/bcs-services/bcs-monitor
go 1.23

require (
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20240315030619-2c36b15d2127
github.com/Tencent/bk-bcs/bcs-common/pkg/audit v0.0.0-20231027074658-46b201bef8d8
github.com/Tencent/bk-bcs/bcs-common/pkg/auth v0.0.0-20231130061921-aba183933987
github.com/Tencent/bk-bcs/bcs-common/pkg/otel v0.0.0-20230901032130-5c3e207129c5
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20241216022845-076cdd3b1a75
github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubebkbcs v0.0.0-20230506100250-1d5620f4abf4
github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20230602131736-2c6f5ea23f31
github.com/chonla/format v0.0.0-20220105105701-1119f4a3f36f
Expand All @@ -16,12 +13,12 @@ require (
github.com/gin-contrib/requestid v0.0.4
github.com/gin-contrib/sse v0.1.0
github.com/gin-gonic/gin v1.9.1
github.com/go-kit/log v0.2.0
github.com/go-kit/log v0.2.1
github.com/go-micro/plugins/v4/registry/etcd v1.1.0
github.com/go-redis/redis/v8 v8.11.5
github.com/go-resty/resty/v2 v2.7.0
github.com/go-resty/resty/v2 v2.12.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.3.1
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-version v1.6.0
Expand All @@ -33,21 +30,21 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.46.0
github.com/prometheus-operator/prometheus-operator/pkg/client v0.46.0
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.41.0
github.com/prometheus/client_golang v1.19.0
github.com/prometheus/common v0.48.0
github.com/prometheus/prometheus v1.8.2-0.20220308163432-03831554a519
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2
github.com/swaggo/gin-swagger v1.4.3
github.com/swaggo/swag v1.8.1
github.com/thanos-io/thanos v0.26.0
go-micro.dev/v4 v4.10.2
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.44.0
go.uber.org/automaxprocs v1.5.1
golang.org/x/sync v0.2.0
google.golang.org/grpc v1.57.0
golang.org/x/sync v0.6.0
google.golang.org/grpc v1.62.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.5.1
Expand All @@ -61,7 +58,8 @@ require (

require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/TencentBlueKing/bk-audit-go-sdk v0.0.5 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/TencentBlueKing/bk-audit-go-sdk v0.0.6 // indirect
github.com/TencentBlueKing/gopkg v1.1.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect
Expand All @@ -70,69 +68,70 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/frankban/quicktest v1.14.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-migrate/migrate/v4 v4.16.2 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/golang-migrate/migrate/v4 v4.17.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/matryer/is v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/onsi/ginkgo/v2 v2.9.2 // indirect
github.com/onsi/gomega v1.27.6 // indirect
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
github.com/openzipkin/zipkin-go v0.3.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/smartystreets/assertions v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.43.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.3.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.3.0 // indirect
go.opentelemetry.io/otel/metric v1.18.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/arch v0.6.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
sigs.k8s.io/controller-runtime v0.11.2 // indirect
)

require (
cloud.google.com/go/compute v1.19.1 // indirect
cloud.google.com/go/trace v1.9.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/trace v1.10.4 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20220824120805-4b6e5c587895 // indirect
github.com/TencentBlueKing/iam-go-sdk v0.1.4 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/TencentBlueKing/iam-go-sdk v0.1.6 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.42.31 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/aws/aws-sdk-go v1.49.6 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.2.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
Expand All @@ -147,9 +146,9 @@ require (
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb // indirect
github.com/felixge/fgprof v0.9.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.4.2 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -161,12 +160,12 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/status v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/providers/kit/v2 v2.0.0-20201002093600-73cf2ae9d891 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2.0.20201207153454-9f6bf00c00a7 // indirect
Expand All @@ -183,12 +182,11 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743 // indirect
github.com/lightstep/lightstep-tracer-go v0.18.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -200,15 +198,15 @@ require (
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/parnurzeal/gorequest v0.2.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/exporter-toolkit v0.7.1 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -217,7 +215,7 @@ require (
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/vimeo/galaxycache v0.0.0-20210323154928-b7e5d71c067a // indirect
github.com/xanzy/ssh-agent v0.3.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.elastic.co/apm v1.11.0 // indirect
go.elastic.co/apm/module/apmhttp v1.11.0 // indirect
Expand All @@ -235,18 +233,18 @@ require (
go.opentelemetry.io/otel/trace v1.18.0
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/tools v0.9.3 // indirect
google.golang.org/api v0.114.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/api v0.150.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand All @@ -266,23 +264,24 @@ require (
require (
github.com/OneOfOne/xxhash v1.2.6 // indirect
github.com/clusternet/clusternet v0.13.0
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-playground/validator/v10 v10.16.0 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.8.1 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
)

replace (
github.com/go-resty/resty/v2 => github.com/ifooth/resty/v2 v2.0.0-20230223083514-3015979960de
// from github.com/thanos-io/thanos
github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common => github.com/prometheus/common v0.34.0
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20220308163432-03831554a519
github.com/thanos-io/thanos => github.com/ifooth/thanos v0.26.1-0.20230707020703-bac1f168813b
Expand Down
3 changes: 3 additions & 0 deletions bcs-services/bcs-monitor/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func (c *Configuration) ReadFrom(content []byte) error {
if c.Mongo.Address == "" {
c.Mongo.Address = MONGO_ADDRESS
}
if c.Mongo.Replicaset == "" {
c.Mongo.Replicaset = MONGO_REPLICASET
}
if c.Mongo.Username == "" {
c.Mongo.Username = MONGO_USERNAME
}
Expand Down
2 changes: 2 additions & 0 deletions bcs-services/bcs-monitor/pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
BKIAM_GATEWAY_SERVER = os.Getenv("BKIAM_GATEWAY_SERVER")
// MONGO_ADDRESS ...
MONGO_ADDRESS = os.Getenv("MONGO_ADDRESS")
// MONGO_REPLICASET ...
MONGO_REPLICASET = os.Getenv("MONGO_REPLICASET")
// MONGO_USERNAME ...
MONGO_USERNAME = os.Getenv("MONGO_USERNAME")
// MONGO_PASSWORD ...
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-monitor/pkg/config/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package config
// MongoConf mongo config
type MongoConf struct {
Address string `yaml:"address"`
Replicaset string `yaml:"replicaset"`
AuthDatabase string `yaml:"authdatabase"`
Database string `yaml:"database"`
Username string `yaml:"username"`
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-monitor/pkg/storage/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func InitStorage() {
mongoConf := config.G.Mongo
mongoOptions := &mongo.Options{
Hosts: strings.Split(mongoConf.Address, ","),
Replicaset: mongoConf.Replicaset,
ConnectTimeoutSeconds: int(mongoConf.ConnectTimeout),
AuthDatabase: mongoConf.AuthDatabase,
Database: mongoConf.Database,
Expand Down

0 comments on commit 744f9f4

Please sign in to comment.