You've already forked mysqld_exporter
mirror of
https://github.com/prometheus/mysqld_exporter.git
synced 2025-07-31 17:44:21 +03:00
Add innodb compression statistic (#275)
* Add innodb commpression statistic https://dev.mysql.com/doc/refman/5.5/en/innodb-cmp-table.html https://dev.mysql.com/doc/refman/5.5/en/innodb-cmpmem-table.html * Add innodb commpression statistic https://dev.mysql.com/doc/refman/5.5/en/innodb-cmp-table.html https://dev.mysql.com/doc/refman/5.5/en/innodb-cmpmem-table.html
This commit is contained in:
committed by
Ben Kochie
parent
1645bb4d70
commit
170f6645e8
76
collector/info_schema_innodb_cmp.go
Normal file
76
collector/info_schema_innodb_cmp.go
Normal file
@ -0,0 +1,76 @@
|
||||
// Scrape `information_schema.INNODB_CMP`.
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const innodbCmpQuery = `
|
||||
SELECT
|
||||
page_size, compress_ops, compress_ops_ok, compress_time, uncompress_ops, uncompress_time
|
||||
FROM information_schema.innodb_cmp
|
||||
`
|
||||
|
||||
var (
|
||||
infoSchemaInnodbCmpCompressOps = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, informationSchema, "innodb_cmp_compress_ops_total"),
|
||||
"Number of times a B-tree page of the size PAGE_SIZE has been compressed.",
|
||||
[]string{"page_size"}, nil,
|
||||
)
|
||||
infoSchemaInnodbCmpCompressOpsOk = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, informationSchema, "innodb_cmp_compress_ops_ok_total"),
|
||||
"Number of times a B-tree page of the size PAGE_SIZE has been successfully compressed.",
|
||||
[]string{"page_size"}, nil,
|
||||
)
|
||||
infoSchemaInnodbCmpCompressTime = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, informationSchema, "innodb_cmp_compress_time_seconds_total"),
|
||||
"Total time in seconds spent in attempts to compress B-tree pages.",
|
||||
[]string{"page_size"}, nil,
|
||||
)
|
||||
infoSchemaInnodbCmpUncompressOps = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, informationSchema, "innodb_cmp_uncompress_ops_total"),
|
||||
"Number of times a B-tree page of the size PAGE_SIZE has been uncompressed.",
|
||||
[]string{"page_size"}, nil,
|
||||
)
|
||||
infoSchemaInnodbCmpUncompressTime = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, informationSchema, "innodb_cmp_uncompress_time_seconds_total"),
|
||||
"Total time in seconds spent in uncompressing B-tree pages.",
|
||||
[]string{"page_size"}, nil,
|
||||
)
|
||||
)
|
||||
|
||||
// ScrapeInnodbCmp collects from `information_schema.innodb_cmp`.
|
||||
func ScrapeInnodbCmp(db *sql.DB, ch chan<- prometheus.Metric) error {
|
||||
|
||||
informationSchemaInnodbCmpRows, err := db.Query(innodbCmpQuery)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer informationSchemaInnodbCmpRows.Close()
|
||||
|
||||
var (
|
||||
page_size string
|
||||
compress_ops, compress_ops_ok, compress_time, uncompress_ops, uncompress_time float64
|
||||
)
|
||||
|
||||
for informationSchemaInnodbCmpRows.Next() {
|
||||
|
||||
if err := informationSchemaInnodbCmpRows.Scan(
|
||||
&page_size, &compress_ops, &compress_ops_ok, &compress_time, &uncompress_ops, &uncompress_time,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(infoSchemaInnodbCmpCompressOps, prometheus.CounterValue, compress_ops, page_size)
|
||||
ch <- prometheus.MustNewConstMetric(infoSchemaInnodbCmpCompressOpsOk, prometheus.CounterValue, compress_ops_ok, page_size)
|
||||
ch <- prometheus.MustNewConstMetric(infoSchemaInnodbCmpCompressTime, prometheus.CounterValue, compress_time, page_size)
|
||||
ch <- prometheus.MustNewConstMetric(infoSchemaInnodbCmpUncompressOps, prometheus.CounterValue, uncompress_ops, page_size)
|
||||
ch <- prometheus.MustNewConstMetric(infoSchemaInnodbCmpUncompressTime, prometheus.CounterValue, uncompress_time, page_size)
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user