Skip to content

Commit 76429c4

Browse files
authored
Merge pull request #19 from rluisr/add/metadata_config_nodes
Breaking: add metadata_config_nodes
2 parents 28fffb3 + 2db48f5 commit 76429c4

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ steps:
1616
- name: deps
1717
path: /go
1818
commands:
19-
- "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2"
19+
- "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin "
2020
- golangci-lint run
2121
when:
2222
event:

gauges.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ var (
2626
Name: "metadata_config",
2727
Help: "metadata config",
2828
}, []string{"name", "cluster_name", "time_refresh_in_ms", "group_replication_id"})
29-
metadataConfigNodeGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
29+
metadataConfigNodesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
3030
Namespace: nameSpace,
31-
Name: "metadata_config_node",
32-
Help: "metadata config node",
33-
}, []string{"name", "router_host", "cluster_name", "hostname", "port"})
31+
Name: "metadata_config_nodes",
32+
Help: "count of metadata config node",
33+
}, []string{"name", "router_host", "cluster_name"})
3434
metadataStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
3535
Namespace: nameSpace,
3636
Name: "metadata_status",

main.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto/tls"
55
"crypto/x509"
66
"fmt"
7-
"io/ioutil"
87
"log"
98
"net/http"
109
"os"
@@ -97,7 +96,7 @@ func initializeClientOptions() (*mysqlrouter.Options, error) {
9796
return nil, err
9897
}
9998

100-
caCert, err := ioutil.ReadFile(caPath)
99+
caCert, err := os.ReadFile(caPath)
101100
if err != nil {
102101
return nil, err
103102
}
@@ -155,10 +154,8 @@ func collectMetrics() {
155154
}
156155
metadataConfigGauge.WithLabelValues(metadata.Name, metadataConfig.ClusterName, strconv.Itoa(metadataConfig.TimeRefreshInMs), metadataConfig.GroupReplicationID)
157156

158-
// config node
159-
for _, metadataConfigNode := range metadataConfig.Nodes {
160-
metadataConfigNodeGauge.WithLabelValues(metadata.Name, router.Hostname, metadataConfig.ClusterName, metadataConfigNode.Hostname, strconv.Itoa(metadataConfigNode.Port))
161-
}
157+
// config nodes count
158+
metadataConfigNodesGauge.WithLabelValues(metadata.Name, router.Hostname, metadataConfig.ClusterName, strconv.Itoa(len(metadataConfig.Nodes)))
162159

163160
// status
164161
if args.CollectMetadataStatus {

0 commit comments

Comments
 (0)