Skip to content

クエリジョブ

クエリジョブのイベントは、どの経路から実行されたかを context で表します。 経路ごとの context の入り方は query_job.create のサンプルにまとめてあります。

イベント一覧

イベントリソース説明
query_job.createquery_jobクエリジョブが作成された。
query_job.get_resultquery_jobクエリジョブの結果が取得された。
query_job.start_exportquery_jobクエリ結果のエクスポートが開始された。
query_job.get_download_urlquery_jobエクスポート結果のダウンロード URL が取得された。
query_job.cancelquery_jobクエリジョブがキャンセルされた。

イベント詳細

query_job.create 準備中

クエリジョブが作成された。

フィールド
event.codequery_job.create
scope.typeworkspace
resource.typequery_job
references(なし)
queryクエリの仕様
change(なし)
grant(なし)
extra(なし)

query

その操作でデータをどう取り出そうとしたかが Query の形で入ります。

サンプル

保存済クエリからの実行
json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
ノートブックの編集画面からの実行

どのノートブック・どのページからの実行かは context.notebook から辿れます。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "notebook": {
      "notebook": {
        "type": "notebook",
        "uid": "63e1be654aa70ad689601bf3",
        "name": "Sales KPI"
      },
      "page": {
        "type": "notebook_page",
        "uid": "671ecbbf2990c63fea3b3a26",
        "name": "Overview"
      }
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
レポートの閲覧中の実行

どのレポート・どのページからの実行かは context.report から辿れます。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "report": {
      "report": {
        "type": "report",
        "uid": "63e1be654aa70ad689601bf5",
        "name": "Weekly Dashboard"
      },
      "notebook": {
        "type": "notebook",
        "uid": "63e1be654aa70ad689601bf3",
        "name": "Sales KPI"
      },
      "page": {
        "type": "notebook_page",
        "uid": "671ecbbf2990c63fea3b3a26",
        "name": "Overview"
      }
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
署名付き埋め込みの閲覧中の実行

actor は APIキーになります。どの埋め込みの誰による操作かは context.signed_embed から補えます。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "signed_embed": {
      "signed_embed": {
        "type": "signed_embed",
        "uid": "671e4c2f9a1b3d0012ab34cd",
        "name": "Partner Embed"
      },
      "notebook": {
        "type": "notebook",
        "uid": "63e1be654aa70ad689601bf3",
        "name": "Sales KPI"
      },
      "page": {
        "type": "notebook_page",
        "uid": "671ecbbf2990c63fea3b3a26",
        "name": "Overview"
      },
      "token_user_id": "user:1234567890"
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
ワークフローのスケジュール実行からの実行

actor はワークフローになります。どのワークフローのどの実行・ステップからの操作かは context.workflow から補えます。スケジュール実行では起動したユーザーは入りません。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "workflow": {
      "workflow": {
        "type": "workflow",
        "uid": "63e1be654aa70ad689601bf8",
        "name": "Nightly Refresh"
      },
      "workflow_job": {
        "type": "workflow_job",
        "uid": "wjob_01"
      },
      "step": {
        "type": "workflow_step",
        "uid": "runQuery_1"
      }
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
ワークフローの今すぐ実行からの実行

actor はワークフローになります。起動したユーザーは context.workflow.triggered_by から補えます。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "workflow": {
      "workflow": {
        "type": "workflow",
        "uid": "63e1be654aa70ad689601bf8",
        "name": "Nightly Refresh"
      },
      "workflow_job": {
        "type": "workflow_job",
        "uid": "wjob_01"
      },
      "step": {
        "type": "workflow_step",
        "uid": "runQuery_1"
      },
      "triggered_by": {
        "type": "user",
        "uid": "63e1be654aa70ad689601bec",
        "email_addr": "taro@example.com"
      }
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
AIエージェントのツールによる実行

どのセッションのどのツールからの実行かは context.ai_agent から辿れます。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "ai_agent": {
      "ai_profile": {
        "type": "ai_profile",
        "uid": "63e1be654aa70ad689601c10",
        "name": "Default"
      },
      "session": {
        "type": "agent_session",
        "uid": "63e1be654aa70ad689601c01",
        "name": "Weekly sales analysis"
      },
      "tool": "run_sql"
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
MCPクライアントからの直接実行

AIエージェントのセッションを経由しないため、ai_agent は付きません。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "mcp": {
      "client": {
        "type": "mcp_client",
        "uid": "cursor-dcr-01",
        "name": "Cursor"
      },
      "oauth_session": {
        "type": "mcp_oauth_session",
        "uid": "oauth_sess_01"
      },
      "scopes": [
        "sql:execute",
        "support:read"
      ]
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}
MCPクライアントから起動したAIエージェントによる実行

実行経路とMCP接続の両方を記録するため、ai_agentmcp が並びます。

json
{
  "event": {
    "code": "query_job.create",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "context": {
    "ai_agent": {
      "ai_profile": {
        "type": "ai_profile",
        "uid": "63e1be654aa70ad689601c10",
        "name": "Default"
      },
      "session": {
        "type": "agent_session",
        "uid": "63e1be654aa70ad689601c01",
        "name": "Weekly sales analysis"
      },
      "tool": "run_sql"
    },
    "mcp": {
      "client": {
        "type": "mcp_client",
        "uid": "cursor-dcr-01",
        "name": "Cursor"
      },
      "oauth_session": {
        "type": "mcp_oauth_session",
        "uid": "oauth_sess_01"
      },
      "scopes": [
        "agent:execute"
      ]
    }
  },
  "query": {
    "type": "sql",
    "text": "SELECT 1"
  },
  ...
}

query_job.get_result 準備中

クエリジョブの結果が取得された。

フィールド
event.codequery_job.get_result
scope.typeworkspace
resource.typequery_job
references(なし)
queryクエリの仕様
change(なし)
grant(なし)
extra(なし)

query

その操作でデータをどう取り出そうとしたかが Query の形で入ります。

サンプル

json
{
  "event": {
    "code": "query_job.get_result",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  "query": {
    "type": "job_result",
    "limit": 1000
  },
  ...
}

query_job.start_export 準備中

クエリ結果のエクスポートが開始された。

フィールド
event.codequery_job.start_export
scope.typeworkspace
resource.typequery_job
references(なし)
query(なし)
change(なし)
grant(なし)
extra(なし)

サンプル

json
{
  "event": {
    "code": "query_job.start_export",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  ...
}

query_job.get_download_url 準備中

エクスポート結果のダウンロード URL が取得された。

フィールド
event.codequery_job.get_download_url
scope.typeworkspace
resource.typequery_job
references(なし)
query(なし)
change(なし)
grant(なし)
extra(なし)

サンプル

json
{
  "event": {
    "code": "query_job.get_download_url",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  ...
}

query_job.cancel 準備中

クエリジョブがキャンセルされた。

フィールド
event.codequery_job.cancel
scope.typeworkspace
resource.typequery_job
references(なし)
query(なし)
change(なし)
grant(なし)
extra(なし)

サンプル

json
{
  "event": {
    "code": "query_job.cancel",
    ...
  },
  "scope": {
    "type": "workspace",
    ...
  },
  "resource": {
    "type": "query_job",
    "uid": "job_0193fa2c",
    "name": null,
    "path": "connection/63e1be654aa70ad689601bef/query_job/job_0193fa2c",
    "parts": [
      {
        "type": "connection",
        "uid": "63e1be654aa70ad689601bef",
        "name": "BigQuery Prod"
      },
      {
        "type": "query_job",
        "uid": "job_0193fa2c",
        "name": null
      }
    ],
    ...
  },
  ...
}

Codatum Audit Events 監査ログイベントカタログ