いつもの前置き
・Splunkには色々なAppがある。
・とはいえコミュニティサポート(英語)のAppは始めるまでにちょっと敷居が高い。
・そこで私がトライした内容は後学のために共有したいと思いここに書き残します。
・ゆるい情報なので参考程度でご勘弁。
更新
- 2021.01.19 最新のAdd-Onに更新したあとに連携失敗していたので[Google Sheets API]を有効化
- 2022.12.17 Add-onのSet Upメニューが見当たらないためワークアラウンドを記載
- 2023.06.24 12.17作成のワークアラウンドも設定しづらいため修正
「Google Spread Sheetを使ってアセット台帳を管理しているが、この台帳情報をSplunk側に自動連携させてサーチ時に参照させたい」
・利用App
Google Import/Export
https://splunkbase.splunk.com/app/2630/
セットアップ手順
参考元の手順はこちら
https://lukemurphey.net/projects/splunk-google-docs/wiki/How_to_setup_app
※github上の詳細版
https://github.com/LukeMurphey/splunk-google-drive/tree/master/src
GDrive連携のAPIセットアップ
- GCPにアクセス
- Google Drive APIを有効化

- IAMと管理 - サービスアカウントをクリック

Splunkセットアップ
- Appをインストール

※2022.12.17: Splunk Ver9.0.2とGoogled Drive App 2.0.6の組み合わせでSetupメニューが表示されなかったため、appのview権限を表示して、Appの起動を実施
※ 2023.06.24 上記ワークアラウンドも設定しづらいため修正
- 「Setup」メニューが見当たらないため下記ワークアラウンド(URLで直接セットアップページにアクセス)を実施
Open the setup view in the app to upload the service account key. The setup view can be accessed at google_drive_setup (e.g. http://MySplunkInstall:8000/en-US/app/search/google_drive_setup).
- GCPで作成したサービスアカウントの鍵を登録!


- 「設定」→「ルックアップ」にて、①テーブルファイルのUploadをして、②ルックアップ定義を実施しておく。
正常動作確認のため1分間隔で取り込みを行い、エラーがなければ後で適切な頻度に戻すことを推奨
以下はトラブルシューティングメモ
- (2021.01.19追加)
- lookupが更新されていないことに気づき、index=_internalにて以下エラーを確認
021-01-19 13:29:54,223 ERROR A general exception was thrown when executing the import
Traceback (most recent call last):
File "/opt/splunk/etc/apps/google_drive/bin/google_spreadsheet.py", line 223, in import_file
last_updated = google_lookup_sync.import_to_lookup_file(lookup_name, None, None, spreadsheet_title, worksheet_name, session_key, create_if_non_existent=False)
File "/opt/splunk/etc/apps/google_drive/bin/google_drive_app/__init__.py", line 379, in import_to_lookup_file
return self.import_to_lookup_file_full_path(destination_full_path, namespace, owner, google_spread_sheet_name, worksheet_name, session_key, create_if_non_existent, lookup_name=lookup_name)
File "/opt/splunk/etc/apps/google_drive/bin/google_drive_app/__init__.py", line 431, in import_to_lookup_file_full_path
google_work_sheet = self.get_or_make_sheet_if_necessary(google_spread_sheet, worksheet_name)
File "/opt/splunk/etc/apps/google_drive/bin/google_drive_app/__init__.py", line 515, in get_or_make_sheet_if_necessary
worksheet = google_spread_sheet.worksheet(worksheet_name)
File "/opt/splunk/etc/apps/google_drive/bin/google_drive_app/gspread/models.py", line 235, in worksheet
sheet_data = self.fetch_sheet_metadata()
File "/opt/splunk/etc/apps/google_drive/bin/google_drive_app/gspread/models.py", line 184, in fetch_sheet_metadata
r = self.client.request('get', url, params=params)
File "/opt/splunk/etc/apps/google_drive/bin/google_drive_app/gspread/client.py", line 79, in request
raise APIError(response)
APIError: {
"error": {
"code": 403,
"message": "Google Sheets API has not been used in project xxxxxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?project=xxxxxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
- エラー内のmessage欄に記載されていた以下APIを有効化することで改善
https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?