@@ -74,6 +74,7 @@ func (ScrapeSlaveStatus) Scrape(ctx context.Context, db *sql.DB, ch chan<- prome
7474 slaveStatusRows * sql.Rows
7575 err error
7676 )
77+ rowCount := 0
7778 // Try the both syntax for MySQL/Percona and MariaDB
7879 for _ , query := range slaveStatusQueries {
7980 slaveStatusRows , err = db .QueryContext (ctx , query )
@@ -98,8 +99,8 @@ func (ScrapeSlaveStatus) Scrape(ctx context.Context, db *sql.DB, ch chan<- prome
9899 if err != nil {
99100 return err
100101 }
101-
102102 for slaveStatusRows .Next () {
103+ rowCount ++
103104 // As the number of columns varies with mysqld versions,
104105 // and sql.Scan requires []interface{}, we need to create a
105106 // slice of pointers to the elements of slaveData.
@@ -133,6 +134,19 @@ func (ScrapeSlaveStatus) Scrape(ctx context.Context, db *sql.DB, ch chan<- prome
133134 }
134135 }
135136 }
137+ var isConfigured float64
138+ if rowCount > 0 {
139+ isConfigured = 1
140+ } else {
141+ isConfigured = 0
142+ }
143+ ch <- prometheus .MustNewConstMetric (
144+ prometheus .NewDesc (
145+ prometheus .BuildFQName (namespace , slaveStatus , "is_configured" ),
146+ "Returns 1 or 0 depending on whether replication is configured." ,
147+ nil , nil ,
148+ ), prometheus .UntypedValue , isConfigured ,
149+ )
136150 return nil
137151}
138152
0 commit comments