「Cube.js」は、npmやyarnでインストールできるオープンソースのWebアプリケーション用分析ツールです。RDBだけでなく、AWS AthenaやGoogle BigQueryなどのサーバーレスクエリエンジンと連携するように設計されています。機能が非常に豊富なので、今回は初期セットアップに的を絞ってご紹介します。
◆ オープンソースのWebアプリケーション分析ツール「Cube.js」
https://cube.dev/

「Cube.js」は、GUIも完備した高機能なWebアプリケーション分析ツールです。
$ npm install -g cubejs-cli
# or
$ yarn global add cubejs-cli
npmまたはyarnでインストールします。
$ cubejs create <プロジェクト名> -d <データベースタイプ>
(データベースタイプ)
postgres
mysql
mongobi
athena
bigquery
redshift
mssql
clickhouse
snowflake
presto
(例)anypicksというプロジェクトかつMysqlの場合
$ cubejs create anypicks -d mysql
続いてデータベースの初期設定をつくります。
- Creating project structure
- Installing server dependencies
npm WARN deprecated joi@14.3.1: This module has moved and is now available at @hapi/joi. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated topo@3.0.3: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
> core-js@2.6.9 postinstall /home/vagrant/raptor/server/raptor/anypicks/node_modules/core-js
> node scripts/postinstall || echo "ignore"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
npm notice created a lockfile as package-lock.json. You should commit this file.
+ @cubejs-backend/server@0.10.16
added 177 packages from 188 contributors and audited 403 packages in 25.991s
found 0 vulnerabilities
- Installing DB driver dependencies
+ @cubejs-backend/mysql-driver@0.10.16
added 14 packages from 28 contributors in 14.039s
- Writing files from template
- anypicks app has been created 🎉
📊 Next step: run dev server
$ cd anypicks
$ npm run dev
$ cd /anypicks
$ ls -alt
drwxrwxr-x 8 501 games 256 7月 24 05:00 .
-rw-rw-r-- 1 501 games 196 7月 24 04:58 index.js
-rw-rw-r-- 1 501 games 307 7月 24 04:58 .env
drwxrwxr-x 3 501 games 96 7月 24 04:58 schema
-rw-rw-r-- 1 501 games 55154 7月 24 04:58 package-lock.json
-rw-rw-r-- 1 501 games 251 7月 24 04:58 package.json
drwxrwxr-x 172 501 games 5504 7月 24 04:58 node_modules
drwxr-xr-x 37 501 games 1184 7月 24 04:58 ..
プロジェクト名で自動作成されたフォルダに移動します。
[vagrant@localhost anypicks]$ vim .env
CUBEJS_DB_HOST=<YOUR_DB_HOST_HERE>
CUBEJS_DB_NAME=<YOUR_DB_NAME_HERE>
CUBEJS_DB_USER=<YOUR_DB_USER_HERE>
CUBEJS_DB_PASS=<YOUR_DB_PASS_HERE>
CUBEJS_DB_TYPE=mysql
CUBEJS_API_SECRET=b7058b3c0aa6b76fdb0b494ba161bc071fbfb0f2f44483f0c9f2cb8f01995f866b496e826f77f15c17753d3b68adb4baef345185c5f95061abbe0938bb051e94
「.env」ファイルに、アプリケーションに接続するDB設定を記載します。
$ npm run dev
以上で設定は完了。モジュールを起動してサイト(http://localhost:4000)にアクセスします。
※ localhostはご自身のホスト情報に書き換えてください。

無事起動しました。

分析するテーブルを選択して

「+」ボタンからGenerate Schemaを実行します。

Exploreに移動して、分析する指標を選びます。今回は「Notices Count」を選択。

すると、Notices Countのグラフが表示されます。検索条件や表示するグラフを変えらることもできます。

そして興味深いのが、結果を取得するReactのコードスニペットを吐き出してくれます。ですので、webサイトの分析レポートの一部として組み込むことも可能です。
他にはダッシュボードなど、色々な機能がありオープンソースとは思えないほどの充実ぶりです。ぜひ、社内のインテリジェンスツールとして活用してみてください。
◆ オープンソースのWebアプリケーション分析ツール「Cube.js」
https://cube.dev/

Mercari Engineering Blog / 4時間前

ITmedia / 5時間前

ITmedia / 5時間前

ITmedia / 5時間前

CNET Japan / 5時間前
![[小ネタ] WindowsでTerraformを試してみた | DevelopersIO](https://s3-ap-northeast-1.amazonaws.com/raptor-photo-production/news_resource/72524/thumbnail_image/terraform-eyecatch.png)
DevelopersIO / 6時間前

DevelopersIO / 6時間前

TechCrunch Japan / 7時間前

ITmedia / 7時間前

TechCrunch Japan / 7時間前

DevelopersIO / 7時間前

ITmedia / 7時間前

DevelopersIO / 8時間前

DevelopersIO / 8時間前

DevelopersIO / 8時間前

CNET Japan / 8時間前

DevelopersIO / 8時間前

DevelopersIO / 8時間前

CNET Japan / 9時間前

DevelopersIO / 9時間前