LoginSignup
7
1

More than 5 years have passed since last update.

Digdagを使って定期的にBigQueryへクエリを投げる

Posted at

digdagのスケジュール実行機能を使って毎日1回、BigQueryへクエリを投げることを実現することを試みる。

環境

  • digdag:0.9.12
  • java:1.8.0_131

ローカルモードでスケジュール実行しないときは正常に動作していたが、スケジュール実行したところ、以下のエラーが発生。

Task failed with unexpected error: Secret not found for key: 'gcp.credential'

サーバモードで動作させたところ正常に動作するようになったため、その手順を以下に記載する。

設定

設定ファイルに以下を記述

~/.config/digdag/config
database.type=h2
database.path=~/digdag/test.db
digdag.secret-access-policy-file=~/.config/digdag/secret-access-policy.yaml
digdag.secret-encryption-key=暗号化に使うKey==
secrets.gcp.credential=~/work/json.key

実行

digdagをserver modeで起動

digdag server -c ~/.config/digdag/config -L ~/digdag/server.log -l debug -O ~/digdag/logs &

workflowを登録

digdag push PJ名

スケジュール設定は以下を参照
https://docs.digdag.io/scheduling_workflow.html#running-scheduler

Secretを登録

digdag secrets --project PJ名 --set gcp.credential=@json.key

server.logを見て正常に動作していることを確認できればOK。

定期的にジョブが実行されていることは確認できたが、ドキュメントに記載してる"digdag sched"を実行ないままscheduledジョブを実行させてる感じなので、正しい使い方なのかどうかまだ確証を持ててない。引き続き色々試してみる。

7
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1