You've already forked mysqld_exporter
mirror of
https://github.com/prometheus/mysqld_exporter.git
synced 2025-07-31 17:44:21 +03:00
Added the last binlog file number metric.
This commit is contained in:
@ -4,6 +4,8 @@ package collector
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
@ -28,6 +30,11 @@ var (
|
||||
"Number of registered binlog files.",
|
||||
[]string{}, nil,
|
||||
)
|
||||
binlogFileNumberDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, binlog, "file_number"),
|
||||
"The last binlog file number.",
|
||||
[]string{}, nil,
|
||||
)
|
||||
)
|
||||
|
||||
// ScrapeBinlogSize colects from `SHOW BINARY LOGS`.
|
||||
@ -71,6 +78,11 @@ func ScrapeBinlogSize(db *sql.DB, ch chan<- prometheus.Metric) error {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
binlogFilesDesc, prometheus.GaugeValue, float64(count),
|
||||
)
|
||||
// The last row contains the last binlog file number.
|
||||
value, _ := strconv.ParseFloat(strings.Split(filename, ".")[1], 64)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
binlogFileNumberDesc, prometheus.GaugeValue, value,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user