Skip to content

Commit 25a4d76

Browse files
author
Adrien ZAGABE
committed
fix: remove unexisting label
1 parent 7e078bd commit 25a4d76

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

collector/pg_top_queries_execution.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,38 @@ var (
2626
statTotalExecutionTime = prometheus.NewDesc(
2727
prometheus.BuildFQName(namespace, statTopQueriesExecutionTime, "total_seconds"),
2828
"Total time spent in the statement, in milliseconds",
29-
[]string{"queryid", "datname", "user"},
29+
[]string{"queryid"},
3030
prometheus.Labels{},
3131
)
3232
statMinimumExecutionTime = prometheus.NewDesc(
3333
prometheus.BuildFQName(namespace, statTopQueriesExecutionTime, "min_time_seconds"),
3434
"Minimum time spent in the statement, in milliseconds",
35-
[]string{"queryid", "datname", "user"},
35+
[]string{"queryid"},
3636
prometheus.Labels{},
3737
)
3838

3939
statMaximumExecutionTime = prometheus.NewDesc(
4040
prometheus.BuildFQName(namespace, statTopQueriesExecutionTime, "max_time_seconds"),
4141
"Maximum time spent in the statement, in milliseconds",
42-
[]string{"queryid", "datname", "user"},
42+
[]string{"queryid"},
4343
prometheus.Labels{},
4444
)
4545

4646
statMeanExecutionTime = prometheus.NewDesc(
4747
prometheus.BuildFQName(namespace, statTopQueriesExecutionTime, "mean_time"),
4848
"Mean time spent in the statement, in milliseconds",
49-
[]string{"queryid", "datname", "user"},
49+
[]string{"queryid"},
5050
prometheus.Labels{},
5151
)
5252

5353
statTopQueryExecutionQuery = `SELECT
54-
pg_get_userbyid(userid) as user,
55-
pg_database.datname,
5654
pg_stat_statements.queryid,
5755
pg_stat_statements.mean_time / 1000.0 as mean_time,
5856
pg_stat_statements.total_time / 1000.0 as total_seconds,
5957
pg_stat_statements.min_time / 1000.0 as min_time_seconds,
6058
pg_stat_statements.max_time / 1000.0 as max_time_seconds,
6159
pg_stat_statements.calls
6260
FROM pg_stat_statements
63-
JOIN pg_database
64-
ON pg_database.id = pg_stat_statements.dbid
6561
ORDER BY total_seconds DESC
6662
LIMIT 100;`
6763
)
@@ -84,16 +80,6 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
8480
return err
8581
}
8682

87-
userLabel := "unknown"
88-
if user.Valid {
89-
userLabel = user.String
90-
}
91-
92-
datnameLabel := "unknown"
93-
if datName.Valid {
94-
datnameLabel = datName.String
95-
}
96-
9783
queryIdLabel := "unknown"
9884
if queryid.Valid {
9985
queryIdLabel = queryid.String
@@ -107,7 +93,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
10793
statTotalExecutionTime,
10894
prometheus.CounterValue,
10995
totalSecondsMetric,
110-
userLabel, datnameLabel, queryIdLabel,
96+
queryIdLabel,
11197
)
11298

11399
meanTimeSecondsMetric := 0.0
@@ -118,7 +104,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
118104
statMeanExecutionTime,
119105
prometheus.CounterValue,
120106
meanTimeSecondsMetric,
121-
userLabel, datnameLabel, queryIdLabel,
107+
queryIdLabel,
122108
)
123109

124110
minTimeSecondsMetric := 0.0
@@ -129,7 +115,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
129115
statMinimumExecutionTime,
130116
prometheus.CounterValue,
131117
minTimeSecondsMetric,
132-
userLabel, datnameLabel, queryIdLabel,
118+
queryIdLabel,
133119
)
134120

135121
maxTimeSecondsMetric := 0.0
@@ -140,7 +126,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
140126
statMaximumExecutionTime,
141127
prometheus.CounterValue,
142128
maxTimeSecondsMetric,
143-
userLabel, datnameLabel, queryIdLabel,
129+
queryIdLabel,
144130
)
145131

146132
callsMetric := 0.0
@@ -152,7 +138,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
152138
statTotalExecutionTime,
153139
prometheus.CounterValue,
154140
callsMetric,
155-
userLabel, datnameLabel, queryIdLabel,
141+
queryIdLabel,
156142
)
157143
}
158144
return nil

0 commit comments

Comments
 (0)