1
0
mirror of https://github.com/prometheus/mysqld_exporter.git synced 2025-07-30 06:43:05 +03:00

Introduce Scraper interface

Signed-off-by: Kamil Dziedzic <arvenil@klecza.pl>
This commit is contained in:
Kamil Dziedzic
2018-02-01 23:33:02 +01:00
parent f76ef420f1
commit f556a61867
47 changed files with 604 additions and 540 deletions

View File

@ -14,6 +14,7 @@ const innodbCmpMemQuery = `
FROM information_schema.innodb_cmpmem
`
// Metric descriptors.
var (
infoSchemaInnodbCmpMemPagesRead = prometheus.NewDesc(
prometheus.BuildFQName(namespace, informationSchema, "innodb_cmpmem_pages_used_total"),
@ -38,7 +39,20 @@ var (
)
// ScrapeInnodbCmp collects from `information_schema.innodb_cmp`.
func ScrapeInnodbCmpMem(db *sql.DB, ch chan<- prometheus.Metric) error {
type ScrapeInnodbCmpMem struct{}
// Name of the Scraper. Should be unique.
func (ScrapeInnodbCmpMem) Name() string {
return informationSchema + ".innodb_cmpmem"
}
// Help describes the role of the Scraper.
func (ScrapeInnodbCmpMem) Help() string {
return "Collect metrics from information_schema.innodb_cmpmem"
}
// Scrape collects data from database connection and sends it over channel as prometheus metric.
func (ScrapeInnodbCmpMem) Scrape(db *sql.DB, ch chan<- prometheus.Metric) error {
informationSchemaInnodbCmpMemRows, err := db.Query(innodbCmpMemQuery)
if err != nil {