Skip to content

Commit c38f73e

Browse files
authored
Update query.go
Scenario : Initially there is no data or zero rows returned for a SQL query for a particular DB and then if we start sql_exporter . In this case, sql_exporter Metrics UI doesn't have any details to show that SQL query is executed and it is failed. With this change, SQL Exported Metrics indicates user on SQL query is executed and it is failed. Below is entry will come in Metrics with this code change. sql_exporter_last_scrape_failed{database="DB",driver="postgres",host="hostNmae",query="sql_exporter_query",sql_job="sql_exporter_query",user="reader"} 1
1 parent 12bc92e commit c38f73e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

query.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (q *Query) Run(conn *connection) error {
6666
if q.AllowZeroRows {
6767
failedScrapes.WithLabelValues(conn.driver, conn.host, conn.database, conn.user, q.jobName, q.Name).Set(0.0)
6868
} else {
69+
failedScrapes.WithLabelValues(conn.driver, conn.host, conn.database, conn.user, q.jobName, q.Name).Set(1.0)
6970
return fmt.Errorf("zero rows returned")
7071
}
7172
}

0 commit comments

Comments
 (0)