Connecting dockerized Postgres server

Issue Summary

I setup Redash using this instruction, and it worked great:

However I’m not sure what information I should fill in to connect the Postgres server that was created at the same time. The docker-compose.yml has the following info for postgres:

postgres:
image: postgres:9.6-alpine
env_file: /opt/redash/env
volumes:
- /opt/redash/postgres-data:/var/lib/postgresql/data
restart: always

Any help would be much appreciated!

The “Name” is something I can fill in anything I suppose, but Database name needs to be something specific? Username and password is not defined in the yml so I’m not sure what to put there…

Hi @svanton ,

the postgresql database set in docker-compose is the one needed by redash to tu and store queries and dashboard.
When creating a datasource to use in a dashboard or query, you have to set connection parameters for that thematic database.

Hi Mathieu,

Thank you, but where do I find those parameters? I used the standard, unaltered, setup script found in the link. I tried looking inside the setup files to see where these parameters are defined but havent found it yet.

Thank you!

I am sorry but I do not understand why you want to connect to redash’s own database ?
If you not want to create a dashboard over your own database, containing your thematic data (which could be one of the supported datasources) you should fill the “new datasource” parameters with the parameters corresponding to your own database server or data source.

For example my database, we I store all the data with produce on the fields is called “work_db” on a postgresql server running on host 10.30.40.111 on port 5432 and a User called redash_reader can connect to.
Those are the parameters I need to create a new datasource in redash to query and visualize.
As you said you can name the datasource as you want.

Hi,

No, sorry i was unclear. I want to store the data on PostgreSQL. The standard setup script (linked in first post) sets up both redash and postgres (and some other stuff apparently) in docker.

The problem Im having is I cant find anywhere on the setup files info about what the parameters are (db name, user, pwd etc). I suppose I could setup a separate postgres server and connect to that maybe.

Location I surmise is ”localhost” since its running on same docker?

All the “other stuff” are redash requirements and redash service “internal tools”

Yes you should have your own database to store thematic information instead of doing that on redash database or redash PostgreSQL instance (which is a 9.6 version).
So you can create a recent PostgreSQL instance using for example PostgreSQL docker images manage and fill it with you own data and then create a redash datasource on it to query it.

Ok, now I got everything up and running (had to reinstall Linux)

So, I have my custom made Postgres server and I have the the Redash containers, all running in Docker.

The custom Postgres is setup using following docker-compose.yml

version: ‘3.1’

services:

db:
image: postgres:latest
restart: always
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: example123
POSTGRES_USER: user2
POSTGRES_DB: nw
POSTGRES_HOST_AUTH_METHOD: trust

adminer:
image: adminer
restart: always
ports:
- 8080:8080

Now as far as I can gather, based on this the parameters that I fill in, in the Redash connect a data source setup, should be:

Name: WhateverIwantToCallIt
Host: 0.0.0.0
Port: 5432
User: user2 (Or blank, since POSTGRES_HOST_AUTH_METHOD: trust)
Password: example123 (Or blank, since POSTGRES_HOST_AUTH_METHOD: trust)
SSL Mode: (not sure, leaving blank)
Database Name: nw

Have I got this right? However, when I try to connect I get the following error:

could not connect to server: Connection refused Is the server running on host “0.0.0.0” and accepting TCP/IP connections on port 5432?

I know the Postgresserver is listening at 0.0.0.0 and port 5432 because in Docker terminal I can see this after I start it.

db_1 | 2020-11-08 13:05:11.013 UTC [1] LOG: listening on IPv4 address “0.0.0.0”, port 5432

Any idea what might be wrong?

Found the solution.

  1. Run the setup.sh from here https://github.com/getredash/setup
  2. Go to “opt/redash/env” in your browser. It will tell you the password of your PostgreSQL server (along with some other stuff I’m not quite sure what it is)
  3. In Redash “Connect a Data Source” enter:

Name: Whatever you want to call it
Host: postgres
Port: I left it blank
User: postgres
Password: The password from opt/redash/env
SSL mode: I left it blank
Database name: postgres