Apache Superset

Overview

Apache Superset is a modern data exploration and visualization platform.

Github: https://github.com/gitorko/project93

We will use a postgres db with a sample db and then create some charts around it in apache superset.

Postgres

Setup postgres & seed the employee database with some data.

1docker run -p 5432:5432 --name pg-container -e POSTGRES_PASSWORD=password -d postgres:9.6.10
2docker ps
3docker exec -it pg-container psql -U postgres -W postgres
4CREATE USER test WITH PASSWORD 'test@123';
5CREATE DATABASE "test-db" WITH OWNER "test" ENCODING UTF8 TEMPLATE template0;
6GRANT ALL PRIVILEGES ON DATABASE "test-db" to test;
7
8docker stop pg-container
9docker start pg-container
1docker exec -i pg-container psql -U postgres < employees.sql
2docker exec -it pg-container psql -U postgres -W postgres
3\c test-db;
4GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "test";
1pwd: password

Download the employee.sql file https://github.com/gitorko/project93/blob/main/employees.sql.zip

Apache Superset

Create the Dockerfile. Pick the python database driver you need to install. In this case its postgres.

{% ghcode https://github.com/gitorko/project93/blob/main/Dockerfile %}

Run the following commands to bring up the superset server

 1docker build -t superset-image .
 2docker run -d -p 8080:8088 --name my-superset superset-image
 3docker exec -it my-superset superset fab create-admin \
 4               --username admin \
 5               --firstname Superset \
 6               --lastname Admin \
 7               --email admin@superset.com \
 8               --password admin
 9docker exec -it my-superset superset db upgrade
10docker exec -it my-superset superset init

If the docker build fails during pip install, update the dns configuration on docker & restart docker

Login to the server

http://localhost:8080/login/

1user: admin
2pwd: admin

You can also load sample database and charts

1docker exec -it my-superset superset load_examples

For the next restart you just need to start the container

1docker start my-superset

Goto Data -> Databases and add the postgres db. Ensure to give the IP address of the machine and not localhost.

1postgresql://test:test@123@10.104.66.186:5432/test-db

Click on datasets and add the tables.

Create a new chart, save the chart and create a dashboard from the chart.

References

https://hub.docker.com/r/apache/superset

https://superset.apache.org/

comments powered by Disqus