You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: collector.go
+31-19
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ import (
17
17
var (
18
18
metricMaps=map[string]map[string]ColumnMapping{
19
19
"stats": {
20
+
"database": {LABEL, "N/A", 1, "N/A"},
20
21
"total_query_count": {COUNTER, "queries_pooled_total", 1, "Total number of SQL queries pooled"},
21
22
"total_query_time": {COUNTER, "queries_duration_seconds", 1e-6, "Total number of seconds spent by pgbouncer when actively connected to PostgreSQL, executing queries"},
22
23
"total_received": {COUNTER, "received_bytes_total", 1, "Total volume in bytes of network traffic received by pgbouncer, shown as bytes"},
@@ -27,6 +28,8 @@ var (
27
28
"total_xact_time": {COUNTER, "server_in_transaction_seconds", 1e-6, "Total number of seconds spent by pgbouncer when connected to PostgreSQL in a transaction, either idle in transaction or executing queries"},
28
29
},
29
30
"pools": {
31
+
"database": {LABEL, "N/A", 1, "N/A"},
32
+
"user": {LABEL, "N/A", 1, "N/A"},
30
33
"cl_active": {GAUGE, "client_active_connections", 1, "Client connections linked to server connection and able to process queries, shown as connection"},
31
34
"cl_waiting": {GAUGE, "client_waiting_connections", 1, "Client connections waiting on a server connection, shown as connection"},
32
35
"sv_active": {GAUGE, "server_active_connections", 1, "Server connections linked to a client connection, shown as connection"},
@@ -111,43 +114,43 @@ func queryNamespaceMapping(ch chan<- prometheus.Metric, db *sql.DB, namespace st
// Prometheus will fail hard if the database and usernames are not UTF-8
129
+
if!utf8.ValidString(labelValues[i]) {
130
+
nonfatalErrors=append(nonfatalErrors, errors.New(fmt.Sprintln("Column %s in %s has an invalid UTF-8 for a label: %s ", columnName, namespace, columnData[idx])))
131
+
continue
132
+
}
133
+
}
134
+
}
135
+
}
136
+
121
137
// Loop over column names, and match to scan data. Unknown columns
122
138
// will be filled with an untyped metric number *if* they can be
123
139
// converted to float64s. NULLs are allowed and treated as NaN.
124
140
foridx, columnName:=rangecolumnNames {
125
-
ifcolumnName=="database" {
126
-
log.Debug("Fetching data for row belonging to database ", columnData[idx])
127
-
database=columnData[idx].(string)
128
-
} elseifcolumnName=="user" {
129
-
log.Debug("Fetching data for row belonging to user ", columnData[idx])
130
-
user=columnData[idx].(string)
131
-
}
132
-
133
141
ifmetricMapping, ok:=mapping.columnMappings[columnName]; ok {
134
142
// Is this a metricy metric?
135
143
ifmetricMapping.discard {
136
144
continue
137
145
}
138
146
139
-
// Prometheus will fail hard if the database and usernames are not UTF-8
0 commit comments