Configuring Apache Superset

Mukund Rastogi
5 min readJun 11, 2021

--

Photo by Isaac Smith on Unsplash

In this article, we learn how to install and configure Apache superset on Linux. I had installed Ubuntu 18.04 on a virtual machine. While installing, I am getting some errors. So I will discuss finding a way to solve errors while installing.

Let’s start with an introduction to Apache Superset.

Apache superset is a data visualization tool that is used by everyone with any skill set to solve real-world business problems through visualization. It is a lightweight, enterprise-ready business intelligence web application. It’s written in python and uses Flask as a web framework library.

Installation and Configuration

Before installation, install updated package information from configured sources on Linux. We can do this by the following command:

sudo apt-get update

Let’s start with installation…

Step 1: Install OS Dependecies

First, we have to install OS-level dependency which is required to install superset.

sudo apt-get install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev

Build-essential:- includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software.

Libssl-dev:- This is a C API. To use it you need to include (at least) OpenSSL/SSL. h and to link your program with libssl library.

Libffi-dev:- The libffi library is useful to anyone trying to build a bridge between interpreted and natively compiled code.

Libsasl2-dev:- This package includes development files for compiling programs with SASL support.

Libldap2-dev:- This package allows the development of LDAP applications using the OpenLDAP libraries.

I had already installed python 3.7 because the new version of Superset requires python 3.7 or above.

Step 2: Upgrade Setup tools and pip

Upgrade pip and setup tools to the latest version using the below command

sudo apt install python3-pip python3-setuptools

Step 3: Create a Python3.7 virtual environment

I had created a python3.7 virtual environment because it uses by default python 3.7 and named this as venv. After creating a virtual environment, activate this.

python3.7 -m venv venv
. venv/bin/activate

Step 4: Install Apache Superset

Follow this command to install Apache Superset

pip3 install apache-superset

Step 5: initialize the database

After installation, initialize your database

superset db upgrade

Step 6: Create an Admin user for Apache Superset

You need to create a user which has Admin rights and you have to enter a username, first name, last name then the password. Using this username and password you can log in to the Apache Superset server.

export FLASK_APP=superset
superset fab create-admin

Step 7: Load Some Example datasets and dashboards

Apache Superset has lots of examples of datasets, dashboards, and charts for practice purposes. You can load that by this

superset load_examples

Step 8: Create default roles and Permissions

After loading Datasets, we need to instantiate the roles(Admin, Alpha, Beta, Gamma) and give permissions to the roles.

superset init

Step 9: start a development server

When you run this command, the flask server runs at localhost whose address is http://127.0.0.1:8088/. After that open this link on your browser to login into Apache Superset.

superset run -p 8088 --with-threads --reload --debugger

Configuring Superset:

Step 1: Create a superset_config.py and add this to your python path

For configuration of superset, first, you need to create a superset_config.py and copy the content from the below image which I have taken from Superset documentation. Add this file to your python folder : — /home/user_name/venv/lib64/python3.7/site-packages/superset

Demonstration of superset_config.py

You can refer here to this file.

Step 2. Some changes required in superset_config.py

Replace SQLALCHEMY_DATABASE_URI = ‘sqlite:////path/to/superset.db’ by:

‘postgresql+psycopg2://{username}:{password}@{host}:{port}/{database}’ if you are using PostgreSQL. You can see database url for other SQL databases engine here

And generate a secret key by running following command on python interpreter

import os
os.urandom(24)

This will generate a unique secret key and write this in superset_config.py file as

SECRET_KEY = ‘\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR”\xa1\xa8’

Now everything is good to go and just need to follow instructions to update the database by running commands written in step 5 and after that start a development server by executing commands in step 9.

Conclusion

At the end, You need to log in on the link which is shown in step 10. Start practicing on the dataset which loaded as an example dataset. This is the first screen which is visible to you.

I will share another blog soon related to all errors which occurred during the installation and configuration of Apache Superset. So follow me for more upcoming blogs. Thanks for giving your time to read this blog.

--

--

Mukund Rastogi

Student | CSE | Machine Learning Enthusiast | intern at AssetPlus Consulting | Programmer |