Superset 是apache的一个孵化项目,定位为一款现代的,准商用BI系统

superset

Apache Superset (incubating) is a modern, enterprise-ready business intelligence web application

Superset 是apache的一个孵化项目,定位为一款现代的,准商用BI系统。

Superset(Caravel)是由Airbnb(知名在线房屋短租公司)开源的数据分析与可视化平台(曾用名Caravel、Panoramix),该工具主要特点是可自助分析、自定义仪表盘、分析结果可视化(导出)、用户/角色权限控制,还集成了一个SQL编辑器,可以进行SQL编辑查询等。

通过superset,可以制作漂亮的统计图表。

预览

_images/bank_dash.png


_images/explore.png


_images/sqllab.png


_images/deckgl_dash.png

superset安装

我们这里直接使用docker

git clone https://github.com/apache/incubator-superset/ cd incubator-superset/contrib/docker # prefix with SUPERSET_LOAD_EXAMPLES=yes to load examples: docker-compose run --rm superset ./docker-init.sh # you can run this command everytime you need to start superset now: docker-compose up

等构建完成后,访问 http://localhost:8088 即可。

想要在自己的应用集成,首先要解决认证

superset 认证分析

superset基于flask-appbuilder开发,security基于flask_appbuilder.security,翻阅其代码,

找到入口: superset/__init__.py:

custom_sm = app.config.get('CUSTOM_SECURITY_MANAGER') or SupersetSecurityManager if not issubclass(custom_sm, SupersetSecurityManager):     raise Exception(         """Your CUSTOM_SECURITY_MANAGER must now extend SupersetSecurityManager,          not FAB's security manager.          See [4565] in UPDATING.md""")  appbuilder = AppBuilder(     app,     db.session,     base_template='superset/base.html',     indexview=MyIndexView,     security_manager_class=custom_sm,     update_perms=get_update_perms_flag(), )  security_manager = appbuilder.sm

默认使用SupersetSecurityManager,继承自SecurityManager

class SupersetSecurityManager(SecurityManager):      def get_schema_perm(self, database, schema):         if schema:             return '[{}].[{}]'.format(database, schema)      def can_access(self, permission_name, view_name):         """Protecting from has_access failing from missing perms/view"""         user = g.user         if user.is_anonymous:             return self.is_item_public(permission_name, view_name)         return self._has_view_access(user, permission_name, view_name)                  ...