Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 178cbd4

Browse files
authored
Merge pull request #46 from ContaAzul/removing-superuser-requirement
Slow Queries: Removing superuser requirement
2 parents d025f63 + d17d838 commit 178cbd4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22

33
A Prometheus exporter for some postgresql metrics.
44

5+
## Getting Started
6+
57
You can add as many database connections as you like to the
68
`config.yml` file, and run it with:
79

810
```console
911
./postgresql_exporter -config=my/config.yml
1012
```
1113

14+
By default some stat views like pg_stat_statements and pg_stat_activity doesn't allow viewing queries run by other users, unless you are a database superuser. Since you probably don't want monitoring to run as a superuser, you can setup, in a AWS RDS instance, a separate monitoring user like this:
15+
16+
```sql
17+
GRANT pg_monitor TO my_monitor_user;
18+
```
19+
1220
Then you can add hostname:9111 to the prometheus scrapes config:
1321

1422
```yml
@@ -25,4 +33,4 @@ graph and alert on them.
2533
2634
```console
2735
docker run -p 9111 -v /path/to/my/config.yml:/config.yml caninjas/postgresql_exporter
28-
```
36+
```

gauges/slow_queries.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ func (g *Gauges) SlowestQueries() *prometheus.GaugeVec {
2828
},
2929
[]string{"query"},
3030
)
31-
if !g.isSuperuser {
32-
log.Warn("postgresql_slowest_queries disabled because it requires a superuser to see queries from other users")
33-
return gauge
34-
}
3531
if !g.hasExtension("pg_stat_statements") {
3632
log.Warn("postgresql_slowest_queries disabled because pg_stat_statements extension is not installed")
3733
return gauge

0 commit comments

Comments
 (0)