apache superset はデータ探索および視覚化プラットフォームです。
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
次ノページにアクセスするとログイン画面にリダイレクトします
USERNAME と PASSWORD に「admin」を入力するとログインできます。
最初からサンプル用のデータベースコネクションが用意されています。
折角なので、作成した DB のコネクションを追加します。
Connect database を選択します
PostgreSQL を選択します
Dataset を作成します
URIpostgresql://examples:examples@db:5432/sample
を入力して
TEST CONNECTION を実行し、「Connection looks good!」が表示されたら、
CONNECT を選択します
データセットを追加します
最初に作った transaction テーブルを対象にします
ダッシュボードタブから確認できるようになりました
ダッシュボードページの公開やダッシュボードレイアウトの変更はダッシュボードページから実施可能です