1
0
mirror of https://github.com/prometheus/mysqld_exporter.git synced 2025-07-31 17:44:21 +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

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