docker單機(jī)搭建superset

superset鏡像

  • 1.構(gòu)建鏡像
    pip.conf 用于替換pip包管理的阿里源,
    build.sh腳本用于構(gòu)建superset運(yùn)行的鏡像環(huán)境
sh build.sh
  • 2.啟動(dòng)容器
sh run_docker.sh
  • 3.配置superset
    config.py文件為superset的配置文件,元數(shù)據(jù)庫(kù)/分布式任務(wù)隊(duì)列的配置分別在其中的101行/408行.
sh config_superset.sh
  • 4.運(yùn)行superset
sh run_superset.sh

superset執(zhí)行流程

默認(rèn)情況下,元數(shù)據(jù)的管理、broker/backend使用的均為sqlite。下圖中為推薦配置。


一條請(qǐng)求的生命周期

superset圖表iframe代碼外嵌

  • 前提條件
    1.config.py中的 WTF_CSRF_ENABLED = False
    2.config.py中的 ENABLE_CORS = True
    3.config.py中的 SUPERSET_WEBSERVER_DOMAINS = ['*'] #包含部署域名
  • 配置public角色權(quán)限
    iframe嵌入代碼中對(duì)應(yīng)圖表對(duì)應(yīng)的數(shù)據(jù)源(pg中的一張表)的權(quán)限要暴露到public角色中。例如下面配置了es數(shù)據(jù)源中hznz_apache_assece這張表的權(quán)限。


    public權(quán)限
  • 外嵌示例:
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <title>iframe</title>
    </head>
    <body>
        <div style="height: 609px;width: 281.25px;">
            <iframe
              width="600"
              height="400"
              seamless
              frameBorder="0"
              scrolling="no"
              src="http://192.168.2.112:8086/superset/explore/?form_data=%7B%22datasource%22%3A%221__table%22%2C%22viz_type%22%3A%22pie%22%2C%22slice_id%22%3A1%2C%22url_params%22%3A%7B%7D%2C%22granularity_sqla%22%3A%22time%22%2C%22time_grain_sqla%22%3Anull%2C%22time_range%22%3A%22Last+year%22%2C%22metric%22%3A%22count%22%2C%22adhoc_filters%22%3A%5B%5D%2C%22groupby%22%3A%5B%22ip%22%5D%2C%22row_limit%22%3A25%2C%22pie_label_type%22%3A%22key%22%2C%22number_format%22%3A%22SMART_NUMBER%22%2C%22donut%22%3Afalse%2C%22show_legend%22%3Atrue%2C%22show_labels%22%3Atrue%2C%22labels_outside%22%3Atrue%2C%22color_scheme%22%3A%22bnbColors%22%2C%22label_colors%22%3A%7B%7D%7D&standalone=true&height=400"
            >
            </iframe>
        <!-- <iframe src="http://dbr.deepdraw.cn/web/monitor/" 
        style="height 100%; width: 100%;" 
        frameborder=0
        </iframe> -->
        </div>
    </body>
</html>

示例
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容