diff --git a/.drone.yml b/.drone.yml index 3c5aab6..6f759a1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ steps: - name: deps path: /go commands: - - "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2" + - "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin " - golangci-lint run when: event: diff --git a/gauges.go b/gauges.go index facec33..a981df0 100644 --- a/gauges.go +++ b/gauges.go @@ -26,11 +26,11 @@ var ( Name: "metadata_config", Help: "metadata config", }, []string{"name", "cluster_name", "time_refresh_in_ms", "group_replication_id"}) - metadataConfigNodeGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ + metadataConfigNodesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: nameSpace, - Name: "metadata_config_node", - Help: "metadata config node", - }, []string{"name", "router_host", "cluster_name", "hostname", "port"}) + Name: "metadata_config_nodes", + Help: "count of metadata config node", + }, []string{"name", "router_host", "cluster_name"}) metadataStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: nameSpace, Name: "metadata_status", diff --git a/main.go b/main.go index 7788b87..c264032 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io/ioutil" "log" "net/http" "os" @@ -97,7 +96,7 @@ func initializeClientOptions() (*mysqlrouter.Options, error) { return nil, err } - caCert, err := ioutil.ReadFile(caPath) + caCert, err := os.ReadFile(caPath) if err != nil { return nil, err } @@ -155,10 +154,8 @@ func collectMetrics() { } metadataConfigGauge.WithLabelValues(metadata.Name, metadataConfig.ClusterName, strconv.Itoa(metadataConfig.TimeRefreshInMs), metadataConfig.GroupReplicationID) - // config node - for _, metadataConfigNode := range metadataConfig.Nodes { - metadataConfigNodeGauge.WithLabelValues(metadata.Name, router.Hostname, metadataConfig.ClusterName, metadataConfigNode.Hostname, strconv.Itoa(metadataConfigNode.Port)) - } + // config nodes count + metadataConfigNodesGauge.WithLabelValues(metadata.Name, router.Hostname, metadataConfig.ClusterName, strconv.Itoa(len(metadataConfig.Nodes))) // status if args.CollectMetadataStatus {