1
0
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:
Roman Vynar
2016-08-17 00:16:13 +03:00
parent ed6f3733b6
commit 6fcc449206
2 changed files with 64 additions and 0 deletions

View File

@ -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
}