Slide 1

Slide 1 text

embulk-input-redash @ariarijp

Slide 2

Slide 2 text

自己紹介 • @ariarijp(Takuya Arita) • 株式会社ユニトーン CTO • http://www.unitone.co.jp/ • Facebook/Twitter広告運用ツールの開発など • だいたい毎日CSVかJSONと戯れています

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Redash • “Redash is an open source tool for teams to query, visualize and collaborate. Redash is quick to setup and works with any data source you might need so you can query from anywhere in no time.” • 様々なデータソースに接続できるデータ活用ツール • クエリーの実行、結果の可視化やダッシュボード表 示などの機能を備える

Slide 5

Slide 5 text

Redash API • 画面からできることはだいたいAPIからも実行・取 得できる • クエリーの実行、結果の取得、再取得(Refresh)な ど • 参考: redashのAPIエンドポイント一覧とリクエス トメソッド • http://qiita.com/ubonsa/items/9a7f4f1d020af88d70c4

Slide 6

Slide 6 text

Embulkも導入しようかと考えていたので Redash APIを使うプラグインを作ってみた

Slide 7

Slide 7 text

embulk-redash-input • RedashのAPIを入力として使用するプラグイン • プラグインを書いたことがなかったのでembulk- input-soracom_harvestを参考に作った • 現時点ではクエリーの再実行(Refresh)をしていな いので、Redash側の結果キャッシュはなんらかの 形で更新されているものとする

Slide 8

Slide 8 text

デモ • Redashのデモ環境で結果を取得 • https://demo.redash.io/queries/3 • GitHub: most active Python repos (by pushes) • APIからの結果取得はembulk-input-redashの役割 • 結果をプッシュ数が5,000を超えるもののみに絞り込む • embulk-filter-row便利 • Markdown Table形式でファイルに書き出す • フォーマットはembulk-formatter-markdown_tableを使う

Slide 9

Slide 9 text

設定ファイル in: type: redash url: https://demo.redash.io/api/queries/3/results.json api_key: {{ env.API_KEY }} columns: - {name: repository_name, type: string} - {name: pushes, type: long} - {name: repository_description, type: string} - {name: repository_url, type: string} filters: - type: row condition: AND conditions: - {column: pushes, operator: ">=", argument: 5000} out: type: file path_prefix: meetup file_ext: md formatter: type: markdown_table encoding: UTF-8 newline: LF 3FEBTI͔Β݁ՌΛ औಘ͢Δͱ͜Ζ ݁ՌΛQVTI͕ Λ ্ճΔ΋ͷʹߜΔ .BSLEPXO5BCMFܗࣜͰ ϑΝΠϧʹॻ͖ग़͢

Slide 10

Slide 10 text

デモの雰囲気 (実行したところ) 2017-05-16 19:34:41.844 +0900: Embulk v0.8.20 2017-05-16 19:34:45.232 +0900 [INFO] (0001:transaction): Loaded plugin embulk- input-redash (0.1.1) 2017-05-16 19:34:45.290 +0900 [INFO] (0001:transaction): Loaded plugin embulk- filter-row (0.3.3) 2017-05-16 19:34:45.332 +0900 [WARN] (0001:transaction): embulk-filter-row: "conditions" is deprecated, use "where" instead. 2017-05-16 19:34:45.339 +0900 [INFO] (0001:transaction): Using local thread executor with max_threads=16 / output tasks 8 = input tasks 1 * 8 2017-05-16 19:34:45.364 +0900 [INFO] (0001:transaction): Loaded plugin embulk- formatter-markdown_table (0.1.0) 2017-05-16 19:34:45.376 +0900 [INFO] (0001:transaction): {done: 0 / 1, running: 0} 2017-05-16 19:34:46.265 +0900 [INFO] (0016:task-0000): Writing local file 'meetup000.00.md' 2017-05-16 19:34:46.273 +0900 [INFO] (0001:transaction): {done: 1 / 1, running: 0} 2017-05-16 19:34:46.325 +0900 [INFO] (main): Committed. 2017-05-16 19:34:46.325 +0900 [INFO] (main): Next config diff: {"in":{},"out":{}}

Slide 11

Slide 11 text

デモの雰囲気 (書き出されたファイル) |repository_name|pushes|repository_description|repository_url| |---|---|---|---| |cosi_monitor|132102||https://github.com/alowell/cosi_monitor| |githubprime|63713||https://github.com/githumtime/githubprime| |livestatus-publicpage|58318|Public status page generator for thruk|https:// github.com/xenim/livestatus-publicpage| |vitality|54612||https://github.com/nctmonitor/vitality| |thruk-pub-status|44509|Public status page generator for thruk|https://github.com/ xenim/thruk-pub-status| |githubtime|38199||https://github.com/githumtime/githubtime| |nova|22456|OpenStack Compute (Nova)|https://github.com/openstack/nova| |edx-platform|18518|the edX learning management system (LMS) and course authoring tool, Studio|https://github.com/edx/edx-platform| |corewar-evolution|15098||https://github.com/sstjohn/corewar-evolution| |odoo|15026|RD Dev Repository|https://github.com/odoo-dev/odoo| |demos|14029|Example Geometry Zen Models.|https://github.com/geometryzen/demos| |HomeworkFox|12864||https://github.com/mindfreakthemon/HomeworkFox|

Slide 12

Slide 12 text

デモの雰囲気 (書き出されたファイルのプレビュー)

Slide 13

Slide 13 text

まとめ • Redash APIを使ってembulk-input-redashを作った • Embulkの仕組みに乗ることでアウトプットを誰かが作った プラグインに任せられるので便利 • embulk-base-restclientの話を聞いてから作ればよかった かもしれない • (RedashのPythonデータソースを使ってごにょごにょとい うのをデモでやってみたかった) • (アウトプットをGoogleスプレッドシートにしたかったけど 準備不足)

Slide 14

Slide 14 text

Thank you!