PostgreSQL
1. Create a read-only user
Section titled “1. Create a read-only user”DataLoris needs to connect, see your schemas and run SELECT aggregates. Give it its own user so you can
audit and revoke it independently.
Run as a database owner or superuser, once per database. Repeat the schema lines for every schema you want to monitor.
CREATE ROLE dataloris_ro LOGIN PASSWORD 'choose-a-strong-password';ALTER ROLE dataloris_ro SET default_transaction_read_only = on;
GRANT CONNECT ON DATABASE shop TO dataloris_ro;
GRANT USAGE ON SCHEMA public TO dataloris_ro;GRANT SELECT ON ALL TABLES IN SCHEMA public TO dataloris_ro;-- Tables created later by the role running this statement:ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO dataloris_ro;ALTER DEFAULT PRIVILEGES only covers tables created by the role that runs it. If your pipelines
create tables as another role, add FOR ROLE etl_user to it.
The built-in pg_read_all_data role grants SELECT on every table, view and sequence, including
future ones.
CREATE ROLE dataloris_ro LOGIN PASSWORD 'choose-a-strong-password';ALTER ROLE dataloris_ro SET default_transaction_read_only = on;GRANT CONNECT ON DATABASE shop TO dataloris_ro;GRANT pg_read_all_data TO dataloris_ro;Besides your tables, DataLoris reads the standard catalogs (information_schema.columns, pg_class,
pg_index, pg_stats and pg_stat_all_tables), which every user can read for tables it has access to.
No extra grant is needed.
2. Add the connection
Section titled “2. Add the connection”-
Open Connections and click Add connection, then choose PostgreSQL.
-
Fill in the fields:
Field Notes Host Public hostname or IP of the server. localhost, internal names and private IPs are refused.Port Defaults to 5432.Database The database to connect to. One connection covers one database. User / Password The read-only user from step 1. SSL mode disable,allow,prefer,require(default),verify-caorverify-full. Keeprequireor stricter. -
Save. The connection is tested automatically and turns ACTIVE when DataLoris can log in.
3. Add tables
Section titled “3. Add tables”In a suite, click Add asset, choose PostgreSQL table, select the connection and enter the table as
schema.table (for example analytics.orders_daily). See assets.
Table freshness on PostgreSQL
Section titled “Table freshness on PostgreSQL”PostgreSQL does not record when a table was last written, so the table freshness
rule watches the table’s write counters (pg_stat_all_tables) instead:
- the first run only records a baseline;
- a change is noticed at the next run, so the precision equals the suite’s schedule;
- it must run against the primary server. Write counters are not replicated, so on a read replica the rule ends in error.
If your connection points at a replica, use column freshness
on an updated_at or created_at column instead.
Troubleshooting
Section titled “Troubleshooting”| Error | Fix |
|---|---|
| The host must be a public address | Use the server’s public hostname or IP. Tunnels to private networks are not supported. |
| destination not allowed | The hostname resolves to a private address. Use a public endpoint. |
| password authentication failed | Check the user and password, and that pg_hba.conf allows the user over the network. |
| no pg_hba.conf entry … SSL off | The server requires SSL: set SSL mode to require. |
| permission denied for table | Grant SELECT on the table (step 1), then run the suite again. |
| timeout | The server is not reachable from the internet, or a firewall blocks DataLoris. |