官方文檔
Python版本
Superset is tested against Python 2.7 and Python 3.4. Airbnb currently uses 2.7.* in production. We do not plan on supporting Python 2.6.
云原生 Cloud-native
Superset is designed to be highly available. It is “cloud-native” as it has been designed scale out in large, distributed environments, and works well inside containers. While you can easily test drive Superset on a modest setup or simply on your laptop, there’s virtually no limit around scaling out the platform. Superset is also cloud-native in the sense that it is flexible and lets you choose your web server (Gunicorn, Nginx, Apache), your metadata database engine (MySQL, Postgres, MariaDB, …), your message queue (Redis, RabbitMQ, SQS, …), your results backend (S3, Redis, Memcached, …), your caching layer (memcached, Redis, …), works well with services like NewRelic, StatsD and DataDog, and has the ability to run analytic workloads against most popular database technologies.
Superset is battle tested in large environments with hundreds of concurrent users. Airbnb’s production environment runs inside Kubernetes and serves 600+ daily active users viewing over 100K charts a day.
The Superset web server and the Superset Celery workers (optional) are stateless, so you can scale out by running on as many servers as needed.
安裝和啟動(dòng)
采用 鏡像 amancevice/superset 進(jìn)行安裝。
注意容器內(nèi)的兩個(gè)路徑,/var/lib/superset
是元數(shù)據(jù)的數(shù)據(jù)庫(kù)地址,/etc/superset or /home/superset
是配置文件的地址。
Volumes
The image defines two data volumes: one for mounting configuration into the container, and one for data (logs, SQLite DBs, &c).
The configuration volume is located alternatively at /etc/superset or /home/superset; either is acceptable. Both of these directories are included in the PYTHONPATH of the image. Mount any configuration (specifically the superset_config.py file) here to have it read by the app on startup.
The data volume is located at /var/lib/superset and it is where you would mount your SQLite file (if you are using that as your backend), or a volume to collect any logs that are routed there. This location is used as the value of the SUPERSET_HOME environmental variable.
? ~ docker search superset
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
amancevice/superset [0.26.3] Superset on Debian+Python3 129 [OK]
tylerfowler/superset An extendable Docker image for Airbnb's Supe… 3
? ~ docker pull amancevice/superset
Using default tag: latest
latest: Pulling from amancevice/superset
0bd44ff9c2cf: Pull complete
2576b77b8a87: Pull complete
4d2fed87d171: Pull complete
Digest: sha256:d85229d3bae54cc5281e52d615a0c4752bfefa0ae62c754c598411b4f8e529cd
Status: Downloaded newer image for amancevice/superset:latest
? ~ mkdir /opt/docker/superset/conf & mkdir /opt/docker/superset/data
? ~ docker run --name superset -u 0 -d -p 8088:8088 -v /opt/docker/superset/conf:/etc/superset -v /opt/docker/superset/data:/var/lib/superset amancevice/superset
aa3fc2b4aadeecc949771844384110e7813ee028cb38bf21d8bbd73fc54c71a5
? ~ docker exec -it superset superset-init
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [admin@fab.org]: admin@qq.com
Password:
Repeat for confirmation:
Recognized Database Authentications.
Admin User admin created.
訪(fǎng)問(wèn)本機(jī) http://localhost:8088/ 即可看到登錄頁(yè)面:
配置文件
#---------------------------------------------------------
# Superset specific config
#---------------------------------------------------------
ROW_LIMIT = 5000
SUPERSET_WEBSERVER_PORT = 8088
#---------------------------------------------------------
#---------------------------------------------------------
# Flask App Builder configuration
#---------------------------------------------------------
# Your App secret key
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'
# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = 'sqlite:////var/lib/superset/superset.db'
# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''
SECRET_KEY
注意在容器啟動(dòng)前就設(shè)置好,值好像跟某些元數(shù)據(jù)有關(guān)系,筆者在第一次啟動(dòng)后修改重啟容器,遇到數(shù)據(jù)源無(wú)法查看的問(wèn)題。
MAPBOX_API_KEY
是支持地圖類(lèi)報(bào)表的服務(wù)提供商mapbox的密鑰,注冊(cè)一個(gè)account后可得,如下圖:
Demo
執(zhí)行命令superset load_examples
可加載樣例數(shù)據(jù)。
[root@VM_41_21_centos ~]# docker exec -it superset superset load_examples
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
Loading examples into <SQLA engine='sqlite:////var/lib/superset/superset.db'>
Creating default CSS templates
Loading energy related dataset
Creating table [wb_health_population] reference
2018-08-09 06:37:26,001:INFO:root:Creating database reference
2018-08-09 06:37:26,056:INFO:root:Database.get_sqla_engine(). Masked URL: sqlite:////var/lib/superset/superset.db
Loading [World Bank's Health Nutrition and Population Stats]
Creating table [wb_health_population] reference
2018-08-09 06:37:37,091:INFO:root:Creating database reference
Creating slices
Creating a World's Health Bank dashboard
Loading [Birth names]
Done loading table!
--------------------------------------------------------------------------------
Creating table [birth_names] reference
2018-08-09 06:37:40,139:INFO:root:Creating database reference
Creating some slices
Creating a dashboard
Loading [Random time series data]
Done loading table!
--------------------------------------------------------------------------------
Creating table [random_time_series] reference
2018-08-09 06:37:41,208:INFO:root:Creating database reference
Creating a slice
Loading [Random long/lat data]
Done loading table!
--------------------------------------------------------------------------------
Creating table reference
2018-08-09 06:37:57,368:INFO:root:Creating database reference
Creating a slice
Loading [Country Map data]
Done loading table!
--------------------------------------------------------------------------------
Creating table reference
2018-08-09 06:37:57,790:INFO:root:Creating database reference
Creating a slice
Loading [Multiformat time series]
Done loading table!
--------------------------------------------------------------------------------
Creating table [multiformat_time_series] reference
2018-08-09 06:37:58,072:INFO:root:Creating database reference
Creating Heatmap charts
Loading [Misc Charts] dashboard
Creating the dashboard
Loading [Paris GeoJson]
Creating table paris_iris_mapping reference
2018-08-09 06:38:00,659:INFO:root:Creating database reference
2018-08-09 06:38:00,704:INFO:root:Database.get_sqla_engine(). Masked URL: sqlite:////var/lib/superset/superset.db
Loading [San Francisco population polygons]
Creating table sf_population_polygons reference
2018-08-09 06:38:00,877:INFO:root:Creating database reference
Loading [Flights data]
2018-08-09 06:38:05,662:INFO:root:Creating database reference
Done loading table!
Loading [BART lines]
Creating table bart_lines reference
2018-08-09 06:38:05,965:INFO:root:Creating database reference
Loading [Multi Line]
Creating table [wb_health_population] reference
2018-08-09 06:38:17,894:INFO:root:Creating database reference
Creating slices
Creating a World's Health Bank dashboard
Done loading table!
--------------------------------------------------------------------------------
Creating table [birth_names] reference
2018-08-09 06:38:20,453:INFO:root:Creating database reference
Creating some slices
Creating a dashboard
Loading DECK.gl demo
Loading deck.gl dashboard
Creating Scatterplot slice
Creating Screen Grid slice
Creating Hex slice
Creating Grid slice
Creating Polygon slice
Creating Arc slice
Creating Path slice
Creating a dashboard
包括幾個(gè)樣例Dashboard:
看幾個(gè)酷炫的地圖報(bào)表:
遇到的坑
1. superset-init 報(bào)錯(cuò)
? ~ docker exec -it superset superset-init
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [admin@fab.org]: admin@qq.com
Password:
Repeat for confirmation:
2018-07-20 00:37:13,146:ERROR:flask_appbuilder.base:'NoneType' object has no attribute 'name'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/flask_appbuilder/base.py", line 469, in _add_permission
self.sm.add_permissions_view(baseview.base_permissions, baseview.__class__.__name__)
File "/usr/local/lib/python3.5/dist-packages/flask_appbuilder/security/manager.py", line 819, in add_permissions_view
if perm_view.permission.name not in base_permissions:
AttributeError: 'NoneType' object has no attribute 'name'
2018-07-20 00:37:13,151:ERROR:flask_appbuilder.base:Add Permission on View Error: 'NoneType' object has no attribute 'name'
2018-07-20 00:37:13,395:ERROR:flask_appbuilder.base:'NoneType' object has no attribute 'name'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/flask_appbuilder/base.py", line 469, in _add_permission
self.sm.add_permissions_view(baseview.base_permissions, baseview.__class__.__name__)
File "/usr/local/lib/python3.5/dist-packages/flask_appbuilder/security/manager.py", line 819, in add_permissions_view
if perm_view.permission.name not in base_permissions:
AttributeError: 'NoneType' object has no attribute 'name'
2018-07-20 00:37:13,395:ERROR:flask_appbuilder.base:Add Permission on View Error: 'NoneType' object has no attribute 'name'
2018-07-20 00:37:13,745:ERROR:flask_appbuilder.base:'NoneType' object has no attribute 'name'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/flask_appbuilder/base.py", line 469, in _add_permission
self.sm.add_permissions_view(baseview.base_permissions, baseview.__class__.__name__)
File "/usr/local/lib/python3.5/dist-packages/flask_appbuilder/security/manager.py", line 819, in add_permissions_view
if perm_view.permission.name not in base_permissions:
AttributeError: 'NoneType' object has no attribute 'name'
2018-07-20 00:37:13,746:ERROR:flask_appbuilder.base:Add Permission on View Error: 'NoneType' object has no attribute 'name'
Recognized Database Authentications.
Admin User admin created.
···
參考了 這個(gè)issue 重新執(zhí)行了命令 superset init
即可。
? ~ docker exec -it superset superset init
2018-07-20 00:41:47,708:INFO:root:Creating database reference
2018-07-20 00:41:47,717:INFO:root:Syncing role definition
2018-07-20 00:41:47,724:INFO:root:Syncing Admin perms
2018-07-20 00:41:47,802:INFO:root:Syncing Alpha perms
2018-07-20 00:41:47,882:INFO:root:Syncing Gamma perms
2018-07-20 00:41:47,958:INFO:root:Syncing granter perms
2018-07-20 00:41:48,033:INFO:root:Syncing sql_lab perms
2018-07-20 00:41:48,108:INFO:root:Fetching a set of all perms to lookup which ones are missing
2018-07-20 00:41:48,181:INFO:root:Creating missing datasource permissions.
2018-07-20 00:41:48,252:INFO:root:Creating missing database permissions.
2018-07-20 00:41:48,254:INFO:root:Creating missing metrics permissions
2018-07-20 00:41:48,258:INFO:root:Cleaning faulty perms
從 github源碼 可以看出來(lái) superset-init
命令是原來(lái)幾個(gè)初始化命令的組合。
2. localhost:8088無(wú)法訪(fǎng)問(wèn)
由于筆者的ss開(kāi)了全局代理模式導(dǎo)致。。。
期間參考其他文章手動(dòng)執(zhí)行了 superset runserver
命令,通過(guò)返回的日志信息可以看到這種啟動(dòng)方式已經(jīng)被 gunicorn 方式替代。
3. 打開(kāi)數(shù)據(jù)源報(bào)錯(cuò)
第一次啟動(dòng)后更改了superset_config.py
里的SECRET_KEY
導(dǎo)致。默認(rèn)值是:
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'
參考文章
Superset搭建及其簡(jiǎn)單使用
可能是目前顏值最高的開(kāi)源BI工具-Superset
superset使用筆記