Skip to content

Commit 344759e

Browse files
Update README with better user grants guidance (#4528)
Update README with better user grants guidance Added notes on grants for the `db-o11y` to access specific schemas.
1 parent f870e56 commit 344759e

File tree

1 file changed

+25
-2
lines changed
  • internal/component/database_observability

1 file changed

+25
-2
lines changed

internal/component/database_observability/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,21 +400,44 @@ show track_activity_query_size;
400400
4kB
401401
```
402402

403-
6. Create a dedicated DB user and grant permissions.
403+
6. Create a dedicated DB user and grant permissions to monitor the DB.
404404

405405
```sql
406406
CREATE USER "db-o11y" WITH PASSWORD '<password>';
407407
GRANT pg_monitor TO "db-o11y";
408408
GRANT pg_read_all_stats TO "db-o11y";
409409
```
410410

411-
7. Verify that the user has been properly created.
411+
7. Verify that the user has been properly created and has the correct privileges for the `pg_stat_statements` extension.
412412

413413
```sql
414414
-- run with the `db-o11y` user
415415
SELECT * FROM pg_stat_statements LIMIT 1;
416416
```
417417

418+
8. Grant the `db-o11y` user additional privileges to access the objects (databases, schemas, tables, views) for which you want to collect detailed information.
419+
420+
For example, connect to a `payments` database and grant access to specific schemas:
421+
422+
```sql
423+
-- switch to the 'payments' database
424+
\c payments
425+
426+
-- grant USAGE and SELECT permissions in the 'public' schema
427+
GRANT USAGE ON SCHEMA public TO "db-o11y";
428+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "db-o11y";
429+
430+
-- grant USAGE and SELECT permissions in the 'tests' schema
431+
GRANT USAGE ON SCHEMA tests TO "db-o11y";
432+
GRANT SELECT ON ALL TABLES IN SCHEMA tests TO "db-o11y";
433+
```
434+
435+
Alternatively, use the predefined role `pg_read_all_data` to grant `USAGE` and `SELECT` permissions to all objects at once:
436+
437+
```sql
438+
GRANT pg_read_all_data TO "db-o11y";
439+
```
440+
418441
### Running and configuring Alloy
419442

420443
1. You need to run the latest Alloy version from the `main` branch. The latest tags are available here on [Docker Hub](https://hub.docker.com/r/grafana/alloy-dev/tags) (for example, `grafana/alloy-dev:v1.10.0-devel-630bcbb` or more recent) . Additionally, the `--stability.level=experimental` CLI flag is necessary for running the `database_observability` component.

0 commit comments

Comments
 (0)