Redash is an excellent tool to quickly build stunning dashboards to present your data. I use it to visualize data from my PostgreSQL databases for various projects, with the reliance in containers being a bit of a letdown for me. This post collects some notes on deploying redash as a group of standalone processes governed by
systemd on my Linux servers. I can even run multiple instances on a single box, which is useful for testing new code versions or providing fully separate dashboards to different projects.
You might want to take a look at this github repo where I keep the template files discussed here.
If you are looking for a tutorial on installing Redash as per the project’s instructions, this is not the right place. The Redash project publishes various pieces of documentation on how to install and configure the software, with this one being my favorite. I am covering a different installation strategy here, that better suits my preferences and requirements.
I run my redash instances behind Nginx – this lets me do a few interesting tricks and provide a single, convenient location to log traffic and apply policies such as rate limits.
At the time of this writing you will need to stick to Python 2.7. Attempting to run under Python 3.7 proved to be futile as a few dependencies simply were not available or failed to compile properly.
# As root apt install redis-server nginx nodejs python2.7
I will not go into details on the Nginx configuration. However my github repo contains a template configuration based on the one I use for my live dashboards.
Redash requires Celery, which is installed as part of the dependencies we will cover in the next section.
The installation process
On my systems, I like to run complex applications as dedicated users. I setup a special
redash user whose home directory will host the code and assets. I also like to be able to run multiple instances of my services – this is useful for testing among other things.
Within this home directory, one or more Python virtual environments will be used to support as many instances of the service as needed. For this example, I will stick to a single instance that I will call
To setup the special user and its corresponding environment, you can follow these steps:
# As root apt install python2.7 useradd --home-dir /home/redash --create-home --comment 'Redash user' cd ~redash mkdir code venv
You might want to configure the newly created
redash account for SSH access or direct login as per your preference. After this step, software download and dependency installation will be performed:
# As the redash user cd ~/code git clone https://github.com/getredash/redash.git virtualenv venv/production ~/venv/production/bin/activate pip install -r ~/code/redash/requirements.txt pip install -r ~/code/redash/requirements_dev.txt pip install -r ~/code/redash/requirements_all_ds.txt
The installation will take a few minutes. In my case there were a few dependencies that were either unavailable or would not compile. Since my primary use case is concerned only with PostgreSQL, this is not a great concern to me.
This is a good time to place the
bash-production-virtualenv file from my github repo into
~redash/. This file will take care of activating the Python virtual environment when
systemd launches the services.
Once dependencies are out of the way, the site can be built:
# As the redash user cd ~/code/redash npm install npm run build
After a few minutes of colorful logs about dependencies being downloaded and massaged, you should be almost ready for the
systemd part, where the Redash components will come to life.
I wrote two
systemd service files that launch
celery and the
manage.py server that Nginx proxies for. The service files are in my github repo. Most likely you will not need to make changes to them, unless you have opted for placing components on different locations or use a different Linux distribution.
redash-production.default – which looks like as follows – contains the required runtime parameters to get Redash running. You will need to edit lines 3, 5 & 7 to include your real domain name; and, line 4 to add your real database coordinates and credentials.
Place this file at
/etc/default/redash-production, where it will be used by the
systemd service definitions later.
Prior to launching Redash, its own PostgreSQL database needs to be initialized. I create this database by hand:
-- As the postgres user CREATE ROLE redash LOGIN UNENCRYPTED PASSWORD 'secret-password'; CREATE DATABASE redash OWNER redash;
Database initialization if performed via the
manage.py program. It needs its environment initialized, as follows:
# As the redash user cd ~/code/redash ln -s /etc/default/redash-production .env ./bin/run ./manage.py database create_tables
If all is well, you will now have a populated
redash database in your PostgreSQL instance.
Simply execute these commands to enable the new
systemd services. Lines 4 and 5 below actually launch the service.
At this point you can visit the Redash URL you defined in your Nginx configuration and complete your setup.