LoginSignup
2
2

More than 1 year has passed since last update.

Bigquery | peco で連続してジョブ詳細を見るシェルスクリプト

Last updated at Posted at 2017-10-05

最近の Bigqueryのジョブの中から、好きなものを選んで詳細を表示する。

  • 連続して何個ものジョブ詳細を見ることが出来る。
  • この例では最新1000件のジョブ履歴から探すようにした。

実行例

走らせるだけ。

bash bq_ls_peco.sh

スクリプト

# Usage
# bash bq_ls_peco.sh [grep_text]
# 
# Example
# bash bq_ls_peco.sh
# bash bq_ls_peco.sh FAILURE

function finish {
  rm .bq_ls_peco
}

trap finish EXIT

function read_bq_jobs {
  echo "Read bq jobs, just wait a minute."
  bq ls -j -a -n 1000 > .bq_ls_peco
}

read_bq_jobs

if [ -n "$1"]; then
  readonly grep_mode='RUNNING\|FAILURE' 
else
  readonly grep_mode=$1
fi

trap
while true; do
  bq show -j --format=prettyjson $(cat .bq_ls_peco | grep "$grep_mode" | peco | awk '{print $1}')

  echo -e "\nPlease enter and another next job, or hit \"exit\" \"reload\""
  read ans

  if [ "$ans" == exit ]; then
   exit
  elif [ "$ans" == reload ]; then
    read_bq_jobs
  fi
done

環境

  • Google Cloud SDK 174.0.0
  • bq 2.0.27
  • bash 4.4

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

2
2
0

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
2
2