Skip to content

Commit 2ef955d

Browse files
committed
change parameter name address -> bind, modify guage -> gauge
1 parent 86ce90b commit 2ef955d

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
go build .
1010
./query-exporter \
1111
--threads=8 \
12-
--address="0.0.0.0:9104" \
12+
--bind="0.0.0.0:9104" \
1313
--config-database="config-database.yml" \
1414
--config-metrics="config-metrics.yml"
1515
```
@@ -19,7 +19,7 @@ go build .
1919
export LOG_LEVEL="debug"
2020
./query-exporter \
2121
--threads=8 \
22-
--address="0.0.0.0:9104" \
22+
--bind="0.0.0.0:9104" \
2323
--config-database="config-database.yml" \
2424
--config-metrics="config-metrics.yml"
2525
```
@@ -67,24 +67,24 @@ metric01:
6767
timeout: 1
6868
metrics:
6969
process_count:
70-
type: guage
70+
type: gauge
7171
description: Session count
7272
labels: ["user","host", "db", "command"]
7373
value: "sessions"
7474
process_session_min_time:
75-
type: guage
75+
type: gauge
7676
description: Session count
7777
labels: ["user","host", "db", "command"]
7878
value: "min_time"
7979
process_session_max_time:
80-
type: guage
80+
type: gauge
8181
description: Session count
8282
labels: ["user","host", "db", "command"]
8383
value: "max_time"
8484
- query: "select count(*) cnt from information_schema.innodb_trx"
8585
metrics:
8686
innodb_trx_count:
87-
type: guage
87+
type: gauge
8888
description: innodb current trx count
8989
labels: []
9090
value: "cnt"
@@ -103,17 +103,17 @@ metric02:
103103
timeout: 2
104104
metrics:
105105
process_count:
106-
type: guage
106+
type: gauge
107107
description: Session count
108108
labels: ["user","host", "db", "command"]
109109
value: "sessions"
110110
process_session_min_time:
111-
type: guage
111+
type: gauge
112112
description: Session count
113113
labels: ["user","host", "db", "command"]
114114
value: "min_time"
115115
process_session_max_time:
116-
type: guage
116+
type: gauge
117117
description: Session count
118118
labels: ["user","host", "db", "command"]
119119
value: "max_time"

collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ func (e *QueryCollector) scrape(instance Instance, ch chan<- prometheus.Metric)
118118
switch strings.ToLower(metric.Type) {
119119
case "counter":
120120
ch <- prometheus.MustNewConstMetric(metric.metricDesc, prometheus.CounterValue, val, labelVals...)
121-
case "guage":
121+
case "gauge":
122122
ch <- prometheus.MustNewConstMetric(metric.metricDesc, prometheus.GaugeValue, val, labelVals...)
123123
default:
124-
log.Errorf("[%s] Metric type support only counter|guage, skip", instance.Name)
124+
log.Errorf("[%s] Metric type support only counter|gauge, skip", instance.Name)
125125
continue
126126
}
127127
}

config-metrics.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ metric01:
1313
timeout: 2
1414
metrics:
1515
process_count:
16-
type: guage
16+
type: gauge
1717
description: Session count
1818
labels: ["user","host", "db", "command"]
1919
value: "sessions"
2020
process_session_min_time:
21-
type: guage
21+
type: gauge
2222
description: Session count
2323
labels: ["user","host", "db", "command"]
2424
value: "min_time"
2525
process_session_max_time:
26-
type: guage
26+
type: gauge
2727
description: Session count
2828
labels: ["user","host", "db", "command"]
2929
value: "max_time"
@@ -42,24 +42,24 @@ metric02:
4242
timeout: 1
4343
metrics:
4444
process_count:
45-
type: guage
45+
type: gauge
4646
description: Session count
4747
labels: ["user","host", "db", "command"]
4848
value: "sessions"
4949
process_session_min_time:
50-
type: guage
50+
type: gauge
5151
description: Session count
5252
labels: ["user","host", "db", "command"]
5353
value: "min_time"
5454
process_session_max_time:
55-
type: guage
55+
type: gauge
5656
description: Session count
5757
labels: ["user","host", "db", "command"]
5858
value: "max_time"
5959
- query: "select count(*) cnt from information_schema.innodb_trx"
6060
metrics:
6161
innodb_trx_count:
62-
type: guage
62+
type: gauge
6363
description: innodb current trx count
6464
labels: []
6565
value: "cnt"

main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import (
1313
log "github.com/sirupsen/logrus"
1414
)
1515

16-
var address string
16+
var bind string
1717
var group map[string]Instances
1818
var collectors map[string]*Collector
1919

2020
const (
2121
defaultQueryTimeout = 1
2222
defaultThreadCount = 32
23-
defaultAddress = "0.0.0.0:9104"
23+
defaultBind = "0.0.0.0:9104"
2424
defaultConfigDatabase = "config-database.yml"
2525
defaultConfigMetrics = "config-metrics.yml"
2626
)
@@ -32,13 +32,13 @@ func main() {
3232
var threads int64
3333
var cfg1, cfg2 string
3434
flag.Int64Var(&threads, "threads", defaultThreadCount, "collector thread count")
35-
flag.StringVar(&address, "address", defaultAddress, "http server port")
35+
flag.StringVar(&bind, "address", defaultBind, "http server port")
3636
flag.StringVar(&cfg1, "config-database", defaultConfigDatabase, "configuration databases")
3737
flag.StringVar(&cfg2, "config-metrics", defaultConfigMetrics, "configuration metrics")
3838
flag.Parse()
3939

4040
// ===========================
41-
log.Debugf("[address] %s", address)
41+
log.Debugf("[bind] %s", bind)
4242
log.Debugf("[threads] %d", threads)
4343
log.Debugf("[config-database] %s", cfg1)
4444
log.Debugf("[config-metrics] %s", cfg2)
@@ -125,7 +125,7 @@ func main() {
125125
}
126126

127127
// Regist http handler
128-
log.Infof("Regist handler %s/%s", address, path)
128+
log.Infof("Regist handler %s/%s", bind, path)
129129
http.HandleFunc("/"+path, func(w http.ResponseWriter, r *http.Request) {
130130
h := promhttp.HandlerFor(prometheus.Gatherers{
131131
prometheus.DefaultGatherer,
@@ -139,8 +139,8 @@ func main() {
139139
// ===========================
140140
// start server
141141
// ===========================
142-
log.Infof("Starting http server - %s", address)
143-
if err = http.ListenAndServe(address, nil); err != nil {
142+
log.Infof("Starting http server - %s", bind)
143+
if err = http.ListenAndServe(bind, nil); err != nil {
144144
log.Fatalf("Failed to start http server: %s", err)
145145
}
146146
}

0 commit comments

Comments
 (0)