@@ -26,42 +26,38 @@ var (
26
26
statTotalExecutionTime = prometheus .NewDesc (
27
27
prometheus .BuildFQName (namespace , statTopQueriesExecutionTime , "total_seconds" ),
28
28
"Total time spent in the statement, in milliseconds" ,
29
- []string {"queryid" , "datname" , "user" },
29
+ []string {"queryid" },
30
30
prometheus.Labels {},
31
31
)
32
32
statMinimumExecutionTime = prometheus .NewDesc (
33
33
prometheus .BuildFQName (namespace , statTopQueriesExecutionTime , "min_time_seconds" ),
34
34
"Minimum time spent in the statement, in milliseconds" ,
35
- []string {"queryid" , "datname" , "user" },
35
+ []string {"queryid" },
36
36
prometheus.Labels {},
37
37
)
38
38
39
39
statMaximumExecutionTime = prometheus .NewDesc (
40
40
prometheus .BuildFQName (namespace , statTopQueriesExecutionTime , "max_time_seconds" ),
41
41
"Maximum time spent in the statement, in milliseconds" ,
42
- []string {"queryid" , "datname" , "user" },
42
+ []string {"queryid" },
43
43
prometheus.Labels {},
44
44
)
45
45
46
46
statMeanExecutionTime = prometheus .NewDesc (
47
47
prometheus .BuildFQName (namespace , statTopQueriesExecutionTime , "mean_time" ),
48
48
"Mean time spent in the statement, in milliseconds" ,
49
- []string {"queryid" , "datname" , "user" },
49
+ []string {"queryid" },
50
50
prometheus.Labels {},
51
51
)
52
52
53
53
statTopQueryExecutionQuery = `SELECT
54
- pg_get_userbyid(userid) as user,
55
- pg_database.datname,
56
54
pg_stat_statements.queryid,
57
55
pg_stat_statements.mean_time / 1000.0 as mean_time,
58
56
pg_stat_statements.total_time / 1000.0 as total_seconds,
59
57
pg_stat_statements.min_time / 1000.0 as min_time_seconds,
60
58
pg_stat_statements.max_time / 1000.0 as max_time_seconds,
61
59
pg_stat_statements.calls
62
60
FROM pg_stat_statements
63
- JOIN pg_database
64
- ON pg_database.id = pg_stat_statements.dbid
65
61
ORDER BY total_seconds DESC
66
62
LIMIT 100;`
67
63
)
@@ -84,16 +80,6 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
84
80
return err
85
81
}
86
82
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
-
97
83
queryIdLabel := "unknown"
98
84
if queryid .Valid {
99
85
queryIdLabel = queryid .String
@@ -107,7 +93,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
107
93
statTotalExecutionTime ,
108
94
prometheus .CounterValue ,
109
95
totalSecondsMetric ,
110
- userLabel , datnameLabel , queryIdLabel ,
96
+ queryIdLabel ,
111
97
)
112
98
113
99
meanTimeSecondsMetric := 0.0
@@ -118,7 +104,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
118
104
statMeanExecutionTime ,
119
105
prometheus .CounterValue ,
120
106
meanTimeSecondsMetric ,
121
- userLabel , datnameLabel , queryIdLabel ,
107
+ queryIdLabel ,
122
108
)
123
109
124
110
minTimeSecondsMetric := 0.0
@@ -129,7 +115,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
129
115
statMinimumExecutionTime ,
130
116
prometheus .CounterValue ,
131
117
minTimeSecondsMetric ,
132
- userLabel , datnameLabel , queryIdLabel ,
118
+ queryIdLabel ,
133
119
)
134
120
135
121
maxTimeSecondsMetric := 0.0
@@ -140,7 +126,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
140
126
statMaximumExecutionTime ,
141
127
prometheus .CounterValue ,
142
128
maxTimeSecondsMetric ,
143
- userLabel , datnameLabel , queryIdLabel ,
129
+ queryIdLabel ,
144
130
)
145
131
146
132
callsMetric := 0.0
@@ -152,7 +138,7 @@ func (PGStatTopQueriesExecutionTime) Update(ctx context.Context, instance *insta
152
138
statTotalExecutionTime ,
153
139
prometheus .CounterValue ,
154
140
callsMetric ,
155
- userLabel , datnameLabel , queryIdLabel ,
141
+ queryIdLabel ,
156
142
)
157
143
}
158
144
return nil
0 commit comments