SecureLink のログを収集する
このドキュメントでは、Google Cloud Storage V2 を使用して SecureLink ログを Google Security Operations に取り込む方法について説明します。
SecureLink(現在は Imprivata Privileged Remote Access)は、安全なベンダー アクセスと特権アクセス管理のためのクラウドベースのサードパーティ リモート アクセス プラットフォームです。SecureLink REST API を使用すると、セッションログ、認証イベント、管理監査ログにプログラムでアクセスできます。
始める前に
次の前提条件を満たしていることを確認してください。
- Google SecOps インスタンス
- Cloud Storage API が有効になっている GCP プロジェクト
- GCS バケットを作成および管理する権限
- GCS バケットの IAM ポリシーを管理する権限
- Cloud Run サービス、Pub/Sub トピック、Cloud Scheduler ジョブを作成する権限
- 管理者権限を持つ SecureLink 管理ポータルへの特権アクセス
- 監査ログの読み取り権限を持つ SecureLink API キー
Google Cloud Storage バケットを作成する
- Google Cloud コンソールに移動します。
- プロジェクトを選択するか、新しいプロジェクトを作成します。
- ナビゲーション メニューで、[Cloud Storage > バケット] に移動します。
- [バケットを作成] をクリックします。
次の構成情報を提供してください。
設定 値 バケットに名前を付ける グローバルに一意の名前を入力します(例: securelink-logs)。ロケーション タイプ ニーズに基づいて選択します(リージョン、デュアルリージョン、マルチリージョン)。 ロケーション ロケーションを選択します(例: us-central1)。ストレージ クラス Standard(頻繁にアクセスされるログにおすすめ) アクセス制御 均一(推奨) 保護ツール 省略可: オブジェクトのバージョニングまたは保持ポリシーを有効にする [作成] をクリックします。
SecureLink API 認証情報を収集する
API キーを生成
- SecureLink 管理ポータルにログインします。
- [Administration] > [API Keys](または [Administration] > [Integrations] > [API])に移動します。
- [API キーを生成] をクリックします。
- API キーの名前(
Google SecOps Integrationなど)を入力します。 - 必要な権限を選択します。
- 監査ログの読み取り: セッション ログと認証ログへのアクセス
- セッションの読み取り: リモート アクセス セッション データへのアクセス
- [生成] をクリックします。
次の詳細をコピーして安全な場所に保存してください。
- API キー: 生成された API キーの値
- Organization ID: SecureLink の組織 ID(管理ポータルの URL または [設定] ページに表示されます)
API ベース URL を特定する
SecureLink API のベース URL:
| 環境 | API ベース URL |
|---|---|
| 本番環境 | https://api.securelink.com/v1 |
テスト API へのアクセス
統合に進む前に、認証情報をテストします。
# Replace with your actual credentials SECURELINK_API_KEY="your-api-key" SECURELINK_ORG_ID="your-org-id" # Test API access - list recent audit logs curl -s -X GET "https://api.securelink.com/v1/audit-logs?limit=1" \ -H "Authorization: Bearer ${SECURELINK_API_KEY}" \ -H "X-Organization-Id: ${SECURELINK_ORG_ID}" \ -H "Accept: application/json"
Cloud Run functions のサービス アカウントを作成する
Cloud Run 関数には、GCS バケットに書き込み、Pub/Sub によって呼び出される権限を持つサービス アカウントが必要です。
サービス アカウントの作成
- GCP Console で、[IAM と管理>サービス アカウント] に移動します。
- [サービス アカウントを作成] をクリックします。
- 次の構成の詳細を入力します。
- サービス アカウント名: 「
securelink-logs-collector-sa」と入力します。 - サービス アカウントの説明:
Service account for Cloud Run function to collect SecureLink logsと入力します。
- サービス アカウント名: 「
- [作成して続行] をクリックします。
- [このサービス アカウントにプロジェクトへのアクセスを許可する] セクションで、次のロールを追加します。
- [ロールを選択] をクリックします。
- [ストレージ オブジェクト管理者] を検索して選択します。
- [+ 別のロールを追加] をクリックします。
- [Cloud Run 起動元] を検索して選択します。
- [+ 別のロールを追加] をクリックします。
- [Cloud Functions 起動元] を検索して選択します。
- [続行] をクリックします。
- [完了] をクリックします。
これらのロールは、次の操作に必要です。
- Storage オブジェクト管理者: ログを GCS バケットに書き込み、状態ファイルを管理する
- Cloud Run 起動元: Pub/Sub が関数を呼び出すことを許可します
- Cloud Functions 起動元: 関数の呼び出しを許可する
GCS バケットに対する IAM 権限を付与する
GCS バケットに対する書き込み権限をサービス アカウントに付与します。
- [Cloud Storage] > [バケット] に移動します。
- バケット名(例:
securelink-logs)をクリックします。 - [権限] タブに移動します。
- [アクセス権を付与] をクリックします。
- 次の構成の詳細を入力します。
- プリンシパルを追加: サービス アカウントのメールアドレス(例:
securelink-logs-collector-sa@PROJECT_ID.iam.gserviceaccount.com)を入力します。 - ロールを割り当てる: [ストレージ オブジェクト管理者] を選択します。
- プリンシパルを追加: サービス アカウントのメールアドレス(例:
- [保存] をクリックします。
Pub/Sub トピックの作成
Cloud Scheduler がパブリッシュし、Cloud Run functions の関数がサブスクライブする Pub/Sub トピックを作成します。
- GCP Console で、[Pub/Sub> トピック] に移動します。
- [トピックを作成] をクリックします。
- 次の構成の詳細を入力します。
- トピック ID: 「
securelink-logs-trigger」と入力します。 - その他の設定はデフォルトのままにします。
- トピック ID: 「
- [作成] をクリックします。
ログを収集する Cloud Run 関数を作成する
Cloud Run 関数は、Cloud Scheduler からの Pub/Sub メッセージによってトリガーされ、SecureLink REST API からログを取得して GCS に書き込みます。
- GCP Console で、[Cloud Run] に移動します。
- [サービスを作成] をクリックします。
- [関数] を選択します(インライン エディタを使用して関数を作成します)。
[構成] セクションで、次の構成の詳細を指定します。
設定 値 サービス名 securelink-logs-collectorリージョン GCS バケットと一致するリージョンを選択します(例: us-central1)。ランタイム [Python 3.12] 以降を選択します。 [トリガー(省略可)] セクションで、次の操作を行います。
- [+ トリガーを追加] をクリックします。
- [Cloud Pub/Sub] を選択します。
- [Cloud Pub/Sub トピックを選択してください] で、トピック
securelink-logs-triggerを選択します。 - [保存] をクリックします。
[認証] セクションで次の操作を行います。
- [認証が必要] を選択します。
- Identity and Access Management(IAM)を確認します。
下にスクロールして、[コンテナ、ネットワーキング、セキュリティ] を開きます。
[セキュリティ] タブに移動します。
- サービス アカウント: サービス アカウント
securelink-logs-collector-saを選択します。
- サービス アカウント: サービス アカウント
[コンテナ] タブに移動します。
- [変数とシークレット] をクリックします。
- 環境変数ごとに [+ 変数を追加] をクリックします。
変数名 値の例 説明 GCS_BUCKETsecurelink-logsGCS バケット名 GCS_PREFIXsecurelinkログファイルの接頭辞 STATE_KEYsecurelink/state.json状態ファイルのパス SECURELINK_API_KEYyour-api-keySecureLink API キー SECURELINK_ORG_IDyour-org-idSecureLink 組織 ID SECURELINK_API_BASEhttps://api.securelink.com/v1SecureLink API のベース URL MAX_RECORDS5000実行あたりの最大レコード数 PAGE_SIZE10001 ページあたりのレコード数 LOOKBACK_HOURS24最初のルックバック期間 [変数とシークレット] セクションで、[リクエスト] まで下にスクロールします。
- リクエストのタイムアウト:
600秒(10 分)を入力します。
- リクエストのタイムアウト:
[設定] タブに移動します。
- [リソース] セクションで次の操作を行います。
- メモリ: 512 MiB 以上を選択します。
- CPU: 1 を選択します。
- [リソース] セクションで次の操作を行います。
[リビジョン スケーリング] セクションで、次の操作を行います。
- [インスタンスの最小数]: 「
0」と入力します。 - インスタンスの最大数:
100と入力します(または、予想される負荷に基づいて調整します)。
- [インスタンスの最小数]: 「
[作成] をクリックします。
サービスが作成されるまで待ちます(1 ~ 2 分)。
サービスが作成されると、インライン コードエディタが自動的に開きます。
関数コードを追加する
- [エントリ ポイント] フィールドに「main」と入力します。
インライン コードエディタで、次の 2 つのファイルを作成します。
最初のファイル main.py:
import functions_framework from google.cloud import storage import json import os import urllib3 from datetime import datetime, timezone, timedelta import time # Initialize HTTP client with timeouts http = urllib3.PoolManager( timeout=urllib3.Timeout(connect=5.0, read=30.0), retries=False, ) # Initialize Storage client storage_client = storage.Client() # Environment variables GCS_BUCKET = os.environ.get('GCS_BUCKET') GCS_PREFIX = os.environ.get('GCS_PREFIX', 'securelink') STATE_KEY = os.environ.get('STATE_KEY', 'securelink/state.json') SECURELINK_API_KEY = os.environ.get('SECURELINK_API_KEY') SECURELINK_ORG_ID = os.environ.get('SECURELINK_ORG_ID') SECURELINK_API_BASE = os.environ.get('SECURELINK_API_BASE', 'https://api.securelink.com/v1') MAX_RECORDS = int(os.environ.get('MAX_RECORDS', '5000')) PAGE_SIZE = int(os.environ.get('PAGE_SIZE', '1000')) LOOKBACK_HOURS = int(os.environ.get('LOOKBACK_HOURS', '24')) def parse_datetime(value: str) -> datetime: """Parse ISO datetime string to datetime object.""" if value.endswith("Z"): value = value[:-1] + "+00:00" return datetime.fromisoformat(value) @functions_framework.cloud_event def main(cloud_event): """ Cloud Run function triggered by Pub/Sub to fetch SecureLink audit and session logs and write to GCS. Args: cloud_event: CloudEvent object containing Pub/Sub message """ if not all([GCS_BUCKET, SECURELINK_API_KEY, SECURELINK_ORG_ID]): print('Error: Missing required environment variables') return try: bucket = storage_client.bucket(GCS_BUCKET) # Load state state = load_state(bucket, STATE_KEY) # Determine time window now = datetime.now(timezone.utc) last_time = None if isinstance(state, dict) and state.get("last_event_time"): try: last_time = parse_datetime(state["last_event_time"]) # Overlap by 2 minutes to catch any delayed events last_time = last_time - timedelta(minutes=2) except Exception as e: print(f"Warning: Could not parse last_event_time: {e}") if last_time is None: last_time = now - timedelta(hours=LOOKBACK_HOURS) print(f"Fetching logs from {last_time.isoformat()} to {now.isoformat()}") # Fetch logs from multiple endpoints all_records = [] newest_event_time = None for endpoint_type in ['audit-logs', 'sessions']: records, newest_time = fetch_logs( endpoint_type=endpoint_type, start_time=last_time, end_time=now, page_size=PAGE_SIZE, max_records=MAX_RECORDS, ) all_records.extend(records) if newest_time: if newest_event_time is None or parse_datetime(newest_time) > parse_datetime(newest_event_time): newest_event_time = newest_time if not all_records: print("No new log records found.") save_state(bucket, STATE_KEY, now.isoformat()) return # Write to GCS as NDJSON timestamp = now.strftime('%Y%m%d_%H%M%S') object_key = f"{GCS_PREFIX}/logs_{timestamp}.ndjson" blob = bucket.blob(object_key) ndjson = '\n'.join([json.dumps(record, ensure_ascii=False) for record in all_records]) + '\n' blob.upload_from_string(ndjson, content_type='application/x-ndjson') print(f"Wrote {len(all_records)} records to gs://{GCS_BUCKET}/{object_key}") # Update state with newest event time if newest_event_time: save_state(bucket, STATE_KEY, newest_event_time) else: save_state(bucket, STATE_KEY, now.isoformat()) print(f"Successfully processed {len(all_records)} records") except Exception as e: print(f'Error processing logs: {str(e)}') raise def load_state(bucket, key): """Load state from GCS.""" try: blob = bucket.blob(key) if blob.exists(): state_data = blob.download_as_text() return json.loads(state_data) except Exception as e: print(f"Warning: Could not load state: {e}") return {} def save_state(bucket, key, last_event_time_iso: str): """Save the last event timestamp to GCS state file.""" try: state = {'last_event_time': last_event_time_iso} blob = bucket.blob(key) blob.upload_from_string( json.dumps(state, indent=2), content_type='application/json' ) print(f"Saved state: last_event_time={last_event_time_iso}") except Exception as e: print(f"Warning: Could not save state: {e}") def fetch_logs(endpoint_type: str, start_time: datetime, end_time: datetime, page_size: int, max_records: int): """ Fetch logs from SecureLink REST API with cursor-based pagination and rate limiting. Args: endpoint_type: API endpoint type (audit-logs, sessions) start_time: Start time for log query end_time: End time for log query page_size: Number of records per page max_records: Maximum total records to fetch Returns: Tuple of (records list, newest_event_time ISO string) """ api_base = SECURELINK_API_BASE.rstrip('/') endpoint = f"{api_base}/{endpoint_type}" headers = { 'Authorization': f'Bearer {SECURELINK_API_KEY}', 'X-Organization-Id': SECURELINK_ORG_ID, 'Accept': 'application/json', 'User-Agent': 'GoogleSecOps-SecureLinkCollector/1.0' } records = [] newest_time = None page_num = 0 backoff = 1.0 cursor = None start_iso = start_time.strftime('%Y-%m-%dT%H:%M:%SZ') end_iso = end_time.strftime('%Y-%m-%dT%H:%M:%SZ') while True: page_num += 1 if len(records) >= max_records: print(f"Reached max_records limit ({max_records}) for {endpoint_type}") break url = f"{endpoint}?startDate={start_iso}&endDate={end_iso}&limit={min(page_size, max_records - len(records))}" if cursor: url += f"&cursor={cursor}" try: response = http.request('GET', url, headers=headers) # Handle rate limiting with exponential backoff if response.status == 429: retry_after = int(response.headers.get('Retry-After', str(int(backoff)))) print(f"Rate limited (429). Retrying after {retry_after}s...") time.sleep(retry_after) backoff = min(backoff * 2, 30.0) continue backoff = 1.0 if response.status != 200: print(f"HTTP Error: {response.status}") response_text = response.data.decode('utf-8') print(f"Response body: {response_text}") return records, newest_time data = json.loads(response.data.decode('utf-8')) page_results = data.get('data', data.get('results', data.get('items', []))) if not page_results: print(f"No more results (empty page) for {endpoint_type}") break print(f"{endpoint_type} page {page_num}: Retrieved {len(page_results)} events") # Add endpoint type for identification for event in page_results: event['_securelink_log_type'] = endpoint_type records.extend(page_results) # Track newest event time for event in page_results: try: event_ts = event.get('timestamp') or event.get('createdAt') or event.get('startTime') if event_ts: event_time = str(event_ts) if newest_time is None or parse_datetime(event_time) > parse_datetime(newest_time): newest_time = event_time except Exception as e: print(f"Warning: Could not parse event time: {e}") # Check for next cursor cursor = data.get('cursor') or data.get('nextCursor') or data.get('next_cursor') if not cursor: if len(page_results) < page_size: print(f"No more pages for {endpoint_type} (last page not full)") else: print(f"No more pages for {endpoint_type} (no cursor)") break except Exception as e: print(f"Error fetching {endpoint_type} logs: {e}") return records, newest_time print(f"Retrieved {len(records)} total {endpoint_type} records from {page_num} pages") return records, newest_time2 つ目のファイル requirements.txt:
functions-framework==3.* google-cloud-storage==2.* urllib3>=2.0.0
[デプロイ] をクリックして、関数を保存してデプロイします。
デプロイが完了するまで待ちます(2 ~ 3 分)。
Cloud Scheduler ジョブの作成
Cloud Scheduler は、定期的に Pub/Sub トピックにメッセージをパブリッシュし、Cloud Run functions の関数をトリガーします。
- GCP Console で、[Cloud Scheduler] に移動します。
- [ジョブを作成] をクリックします。
次の構成情報を提供してください。
設定 値 名前 securelink-logs-collector-hourlyリージョン Cloud Run functions と同じリージョンを選択する 周波数 0 * * * *(1 時間ごとに正時)タイムゾーン タイムゾーンを選択します(UTC を推奨) ターゲット タイプ Pub/Sub トピック トピック securelink-logs-triggerを選択します。メッセージ本文 {}(空の JSON オブジェクト)[作成] をクリックします。
スケジュールの頻度のオプション
ログの量とレイテンシの要件に基づいて頻度を選択します。
| 頻度 | CRON 式 | ユースケース |
|---|---|---|
| 5 分おき | */5 * * * * |
大容量、低レイテンシ |
| 15 分ごと | */15 * * * * |
検索ボリュームが普通 |
| 1 時間ごと | 0 * * * * |
標準(推奨) |
| 6 時間ごと | 0 */6 * * * |
少量、バッチ処理 |
| 毎日 | 0 0 * * * |
過去のデータの収集 |
統合をテストする
- Cloud Scheduler コンソールで、ジョブを見つけます。
- [強制実行] をクリックして、ジョブを手動でトリガーします。
- 数秒待ちます。
- Cloud Run > サービスに移動します。
securelink-logs-collectorをクリックします。- [Logs] タブをクリックします。
関数が正常に実行されたことを確認します。以下のものを探します。
Fetching logs from YYYY-MM-DDTHH:MM:SS+00:00 to YYYY-MM-DDTHH:MM:SS+00:00 audit-logs page 1: Retrieved X events sessions page 1: Retrieved X events Wrote X records to gs://securelink-logs/securelink/logs_YYYYMMDD_HHMMSS.ndjson Successfully processed X records[Cloud Storage] > [バケット] に移動します。
バケット名(
securelink-logs)をクリックします。securelink/フォルダに移動します。現在のタイムスタンプで新しい
.ndjsonファイルが作成されたことを確認します。
ログにエラーが表示された場合:
- HTTP 401: 環境変数の API キーと組織 ID を確認する
- HTTP 403: SecureLink 管理ポータルで API キーに必要な権限があることを確認する
- HTTP 429: レート制限 - 関数はバックオフで自動的に再試行されます
- 環境変数が不足している: 必要な変数がすべて設定されていることを確認します
SecureLink のログを取り込むように Google SecOps でフィードを構成する
- [SIEM 設定] > [フィード] に移動します。
- [Add New Feed] をクリックします。
- [単一フィードを設定] をクリックします。
- [フィード名] フィールドに、フィードの名前を入力します(例:
SecureLink Logs)。 - [ソースタイプ] として [Google Cloud Storage V2] を選択します。
- [ログタイプ] として [SecureLink] を選択します。
[サービス アカウントを取得する] をクリックします。一意のサービス アカウントのメールアドレスが表示されます(例:)。
chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.comこのメールアドレスをコピーします。
[次へ] をクリックします。
次の入力パラメータの値を指定します。
ストレージ バケットの URL: 接頭辞パスを含む GCS バケット URI を入力します。
gs://securelink-logs/securelink/- 次のように置き換えます。
securelink-logs: GCS バケット名。securelink: ログが保存されるオプションの接頭辞/フォルダパス(ルートの場合は空のままにします)。
- 次のように置き換えます。
Source deletion option: 必要に応じて削除オプションを選択します。
- なし: 転送後にファイルを削除しません(テストにおすすめ)。
- 転送されたファイルを削除する: 転送が完了した後にファイルを削除します。
転送されたファイルと空のディレクトリを削除する: 転送が完了した後にファイルと空のディレクトリを削除します。
ファイルの最大経過日数: 過去の日数内に変更されたファイルを含めます(デフォルトは 180 日)。
アセットの名前空間: アセットの名前空間
Ingestion labels: このフィードのイベントに適用されるラベル
[次へ] をクリックします。
[Finalize] 画面で新しいフィードの設定を確認し、[送信] をクリックします。
Google SecOps サービス アカウントに IAM 権限を付与する
Google SecOps サービス アカウントには、GCS バケットに対する Storage オブジェクト閲覧者ロールが必要です。
- [Cloud Storage] > [バケット] に移動します。
- バケット名をクリックします。
- [権限] タブに移動します。
- [アクセス権を付与] をクリックします。
- 次の構成の詳細を入力します。
- プリンシパルを追加: Google SecOps サービス アカウントのメールアドレスを貼り付けます。
- ロールを割り当てる: [Storage オブジェクト閲覧者] を選択します。
- [保存] をクリックします。
UDM マッピング テーブル
| ログフィールド | UDM マッピング | ロジック |
|---|---|---|
| additional_classification | additional.fields | ベンダー固有の重要なイベントデータで、UDM モデルの正式なセクション内で適切に表現できないもの |
| mechanism | extensions.auth.mechanism | 認証メカニズム |
| extensions.auth.type | 認証タイプ | |
| msg、inner_message、desc | metadata.description | イベントの説明 |
| metadata.event_type | イベントのタイプ(例: USER_LOGIN、NETWORK_CONNECTION) | |
| resource_name, _application_protocol | network.application_protocol | アプリケーション プロトコル(HTTP、FTP など) |
| method | network.http.method | HTTP メソッド(GET、POST など) |
| network.ip_protocol | IP プロトコル(TCP、UDP など) | |
| sessionId | network.session_id | セッション ID |
| principal_host | principal.hostname | 送信元ホスト名 |
| login_ip、src_ip、inner_ip、principal_host | principal.ip | 接続の送信元 IP アドレス |
| principal_port | principal.port | 送信元ポート番号 |
| process_id | principal.process.pid | プロセス ID |
| principal_uri | principal.url | プリンシパルに関連付けられた URL |
| username、key | principal.user.email_addresses | ユーザーに関連付けられているメールアドレス |
| username、key、user_id | principal.user.userid | ユーザー ID |
| security_action | security_result.action | 実行されたアクション(ALLOW、BLOCK など) |
| category | security_result.category | セキュリティ結果のカテゴリ |
| action、description | security_result.description | セキュリティ結果の説明 |
| priority | security_result.priority | セキュリティ結果の優先度 |
| method | security_result.severity | セキュリティ結果の重大度 |
| priority | security_result.severity_details | 重大度の詳細 |
| reason | security_result.summary | セキュリティ結果の概要 |
| application、product_event_type | target.application | アプリケーション名 |
| pwd | target.file.full_path | ファイルのフルパス |
| target_host | target.hostname | 宛先ホスト名 |
| dst_ip、target_host | target.ip | 宛先 IP アドレス |
| target_port | target.port | 宛先ポート番号 |
| コマンド | target.process.command_line | プロセスのコマンドライン |
| target.resource.type | リソースのタイプ | |
| URL | target.url | ターゲットに関連付けられた URL |
| username、key | target.user.email_addresses | ターゲット ユーザーに関連付けられているメールアドレス |
| name | target.user.user_display_name | ユーザーの表示名 |
| username、key、user_id | target.user.userid | 対象ユーザーのユーザー ID |
| metadata.product_name | 商品名 | |
| metadata.vendor_name | ベンダー/会社名 |
さらにサポートが必要な場合 コミュニティ メンバーや Google SecOps のプロフェッショナルから回答を得ることができます。