Skip to content

Latest commit

 

History

History
121 lines (88 loc) · 4.22 KB

supersetを使ってみる.md

File metadata and controls

121 lines (88 loc) · 4.22 KB

apache superset を使ってみる

apache superset はデータ探索および視覚化プラットフォームです。

https://superset.apache.org/

superset を docker イメージを使用して起動します。

git clone --depth=1  https://github.com/apache/superset.git
cd superset
docker compose -f docker-compose-image-tag.yml up
・・・
[+] Running 6/6
 ✔ Container superset_db           Created                                            0.4s
 ✔ Container superset_cache        Created                                            0.4s
 ✔ Container superset_app          Created                                            0.1s
 ✔ Container superset_init         Created                                            0.1s
 ✔ Container superset_worker       Created                                            0.1s
 ✔ Container superset_worker_beat  Created                                            0.1s

DB とテーブルを作成します

docker exec -it superset_db bash
root@55c442e52341:/# createdb -U superset sample
root@55c442e52341:/# psql -U superset -d sample

sample=# CREATE TABLE transactions (
   time TIMESTAMPTZ,
   block_id INT,
   hash TEXT,
   size INT,
   weight INT,
   is_coinbase BOOLEAN,
   output_total BIGINT,
   output_total_usd DOUBLE PRECISION,
   fee BIGINT,
   fee_usd DOUBLE PRECISION,
   details JSONB
);
CREATE TABLE
sample=# CREATE INDEX hash_idx ON public.transactions USING HASH (hash);
CREATE INDEX block_idx ON public.transactions (block_id);
CREATE UNIQUE INDEX time_hash_idx ON public.transactions (time, hash);
CREATE INDEX
CREATE INDEX
CREATE INDEX
sample=# GRANT SELECT ON transactions TO PUBLIC;
GRANT
sample=#\q

wget をインストール後、サンプルデータをダウンロード

apt-get update && apt-get install -y wget
apt-get update && apt-get install -y unzip
wget https://assets.timescale.com/docs/downloads/bitcoin-blockchain/bitcoin_sample.zip
root@55c442e52341:/# unzip bitcoin_sample.zip
Archive:  bitcoin_sample.zip
  inflating: tutorial_bitcoin_sample.csv

データを取り込みます

root@55c442e52341:/# psql -U superset -d sample
sample=# \COPY transactions FROM 'tutorial_bitcoin_sample.csv' CSV HEADER;
COPY 2719085

次ノページにアクセスするとログイン画面にリダイレクトします

http://localhost:8088/

1

USERNAME と PASSWORD に「admin」を入力するとログインできます。

最初からサンプル用のデータベースコネクションが用意されています。

2

折角なので、作成した DB のコネクションを追加します。

Connect database を選択します

3

PostgreSQL を選択します

3

Dataset を作成します

2

SQL Alchemy 経由で接続します 4

URIpostgresql://examples:examples@db:5432/sampleを入力して
TEST CONNECTION を実行し、「Connection looks good!」が表示されたら、 CONNECT を選択します

5

データセットを追加します
最初に作った transaction テーブルを対象にします

5

適用にグラフを作成し、ダッシュボードに追加します 8

ダッシュボードタブから確認できるようになりました

9

ダッシュボードページの公開やダッシュボードレイアウトの変更はダッシュボードページから実施可能です