Netskope アラートログを収集する
このドキュメントでは、Cloud Storage V2 を使用して Netskope Alerts ログを Google Security Operations に取り込む方法について説明します。Netskope は、クラウド サービス、ウェブサイト、プライベート アプリケーションにリアルタイムのデータ保護と脅威保護を提供するクラウド セキュリティ プラットフォームです。Netskope のアラートは、SaaS、IaaS、ウェブ トラフィック全体で、DLP 違反、マルウェア検出、異常な動作、認証情報の侵害、ポリシー違反などのセキュリティ イベントをキャプチャします。
詳細については、Netskope アラートログを収集するをご覧ください。
始める前に
次の前提条件を満たしていることを確認します。
- Google SecOps インスタンス。
- Cloud Storage API が有効になっている Google Cloud プロジェクト。
- Cloud Storage バケットと Identity and Access Management(IAM)ポリシーを作成、管理するための権限。
- Cloud Run サービス、Pub/Sub トピック、Cloud Scheduler ジョブを作成する権限。
- Netskope テナント管理コンソールへの特権アクセス。
- アラートの読み取り権限を持つ Netskope REST API v2 トークン。
Netskope API v2 認証情報を収集する
REST API v2 トークンを作成する
- Netskope テナント管理コンソール(例:
https://your-tenant.goskope.com)にログインします。 - [Settings] > [Tools] > [REST API v2] に移動します。
- [New Token] をクリックします。
- 次の構成情報を指定します。
- トークン名: わかりやすい名前を入力します(例:
SecOps-Alert-Integration)。 - 有効期限: セキュリティ ポリシーに従ってトークンの有効期限を設定します。
- トークン名: わかりやすい名前を入力します(例:
- [エンドポイント] で、次の項目を有効にします。
/api/v2/events/data/alert- 読み取り権限。
- [保存] をクリックします。
- トークン値をコピーして安全に保存します。トークンは 1 回だけ表示されます。
API アクセスを確認する
統合に進む前に、認証情報をテストします。
NETSKOPE_TENANT="[https://your-tenant.goskope.com](https://your-tenant.goskope.com)" API_TOKEN="your-api-v2-token" curl -v -H "Netskope-Api-Token: ${API_TOKEN}" \ "${NETSKOPE_TENANT}/api/v2/events/data/alert?limit=1"
Cloud Storage バケットを作成する
- Google Cloud コンソールに移動します。
- プロジェクトを選択するか、新しいプロジェクトを作成します。
- ナビゲーション メニューで、[Cloud Storage] > [バケット] に移動します。
- [バケットを作成] をクリックします。
次の構成情報を提供してください。
設定 値 バケットに名前を付ける グローバルに一意の名前( netskope-alerts-logsなど)を入力します。ロケーション タイプ ニーズに応じて選択します(リージョン、デュアルリージョン、マルチリージョン)。 ロケーション Google SecOps インスタンスに最も近いロケーションを選択します。 ストレージ クラス 標準(頻繁にアクセスされるログに推奨) アクセス制御 均一(推奨) [作成] をクリックします。
Cloud Run functions のサービス アカウントを作成する
Cloud Run functions の関数には、Cloud Storage バケットへの書き込み権限と、Pub/Sub による呼び出し権限を持つサービス アカウントが必要です。
サービス アカウントの作成
- Google Cloud コンソールで、[IAM と管理] > [サービス アカウント] に移動します。
- [サービス アカウントを作成] をクリックします。
- 次の構成情報を指定します。
- サービス アカウント名:
netskope-alerts-collector-sa - サービス アカウントの説明:
Service account for Cloud Run function to collect Netskope Alerts logs。
- サービス アカウント名:
- [作成して続行] をクリックします。
- [このサービス アカウントにプロジェクトへのアクセスを許可する] セクションで、次のロールを追加します。
- ストレージのオブジェクト管理者
- Cloud Run 起動元
- Cloud Functions 起動元
- [続行]、[完了] の順にクリックします。
Cloud Storage バケットに対する IAM 権限を付与する
- [Cloud Storage] > [バケット] に移動します。
netskope-alerts-logsバケットをクリックします。- [権限] タブに移動します。
- [アクセス権を付与] をクリックします。
- 次の構成情報を指定します。
- プリンシパルを追加: サービス アカウントのメールアドレス(例:
netskope-alerts-collector-sa@PROJECT_ID.iam.gserviceaccount.com)を入力します。 - ロールを割り当てる: [Storage オブジェクト管理者] を選択します。
- プリンシパルを追加: サービス アカウントのメールアドレス(例:
- [保存] をクリックします。
Pub/Sub トピックの作成
Cloud Scheduler がパブリッシュし、Cloud Run functions の関数がサブスクライブする Pub/Sub トピックを作成します。
- Google Cloud コンソールで、[Pub/Sub] > [トピック] に移動します。
- [トピックを作成] をクリックします。
- 次の構成情報を指定します。
- トピック ID:
netskope-alerts-trigger。 - その他の設定はデフォルトのままにします。
- トピック ID:
- [作成] をクリックします。
ログを収集する Cloud Run 関数を作成する
Cloud Run 関数は、Cloud Scheduler からの Pub/Sub メッセージによってトリガーされ、Netskope REST API v2 からアラートを取得して Cloud Storage に書き込みます。
- Google Cloud コンソールで Cloud Run に移動します。
- [サービスを作成] をクリックします。
- [関数] を選択します。
[構成] セクションで、次の構成の詳細を入力します。
設定 値 サービス名 netskope-alerts-collectorリージョン Cloud Storage バケットに一致するリージョンを選択します(例: us-central1)。ランタイム Python 3.12 以降 [トリガー] セクションで次の操作を行います。
- [+ トリガーを追加] をクリックします。
- [Cloud Pub/Sub] を選択します。
- [Cloud Pub/Sub トピックを選択してください] で、
netskope-alerts-triggerを選択します。 - [保存] をクリックします。
[認証] セクションで、[認証が必要] を選択し、[Identity and Access Management(IAM)] をオンにします。
[コンテナ、ネットワーキング、セキュリティ] まで下にスクロールします。
[セキュリティ] タブで、サービス アカウント
netskope-alerts-collector-saを選択します。[コンテナ] タブで [変数とシークレット] をクリックし、次の項目を追加します。
変数名 値の例 説明 GCS_BUCKETnetskope-alerts-logsCloud Storage バケットの名前 GCS_PREFIXnetskope/alertsログファイルの接頭辞 STATE_KEYnetskope/alerts/state.json状態ファイルのパス NETSKOPE_TENANThttps://your-tenant.goskope.comNetskope テナント URL NETSKOPE_API_TOKENyour-api-v2-tokenREST API v2 トークン MAX_RECORDS50001 回の実行あたりの最大レコード数 PAGE_SIZE10001 ページあたりのレコード数 LOOKBACK_HOURS24最初のルックバック期間 [リクエスト] セクションで、[リクエスト タイムアウト] を
600秒に設定します。[設定] タブ(リソース)で、[512 MiB] のメモリと [1] の CPU を選択します。
[作成] をクリックします。サービスが作成されると、インライン コードエディタが自動的に開きます。
関数コードを追加する
- [エントリ ポイント] フィールドに「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 http = urllib3.PoolManager( timeout=urllib3.Timeout(connect=5.0, read=30.0), retries=False, ) storage_client = storage.Client() GCS_BUCKET = os.environ.get('GCS_BUCKET') GCS_PREFIX = os.environ.get('GCS_PREFIX', 'netskope/alerts') STATE_KEY = os.environ.get('STATE_KEY', 'netskope/alerts/state.json') NETSKOPE_TENANT = os.environ.get('NETSKOPE_TENANT') NETSKOPE_API_TOKEN = os.environ.get('NETSKOPE_API_TOKEN') 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 to_epoch_seconds(dt): if dt.tzinfo is None: dt = dt.replace(tzinfo=timezone.utc) return int(dt.timestamp()) def parse_datetime(value): if isinstance(value, (int, float)): return datetime.fromtimestamp(value, tz=timezone.utc) if isinstance(value, str): if value.endswith("Z"): value = value[:-1] + "+00:00" return datetime.fromisoformat(value) return None @functions_framework.cloud_event def main(cloud_event): if not all([GCS_BUCKET, NETSKOPE_TENANT, NETSKOPE_API_TOKEN]): print('Error: Missing required environment variables') return try: bucket = storage_client.bucket(GCS_BUCKET) state = load_state(bucket, STATE_KEY) 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"]) 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 alerts from {last_time.isoformat()} to {now.isoformat()}") records, newest_event_time = fetch_alerts( tenant=NETSKOPE_TENANT, token=NETSKOPE_API_TOKEN, start_time=last_time, end_time=now, page_size=PAGE_SIZE, max_records=MAX_RECORDS, ) if not records: print("No new alert records found.") save_state(bucket, STATE_KEY, to_epoch_seconds(now)) return timestamp = now.strftime('%Y%m%d_%H%M%S') object_key = f"{GCS_PREFIX}/alerts_{timestamp}.ndjson" blob = bucket.blob(object_key) ndjson = '\n'.join([json.dumps(r, ensure_ascii=False) for r in records]) + '\n' blob.upload_from_string(ndjson, content_type='application/x-ndjson') print(f"Wrote {len(records)} records to gs://{GCS_BUCKET}/{object_key}") if newest_event_time: save_state(bucket, STATE_KEY, newest_event_time) else: save_state(bucket, STATE_KEY, to_epoch_seconds(now)) print(f"Successfully processed {len(records)} records") except Exception as e: print(f'Error processing alerts: {str(e)}') raise def load_state(bucket, key): 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): try: state = {'last_event_time': last_event_time} 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}") except Exception as e: print(f"Warning: Could not save state: {e}") def fetch_alerts(tenant, token, start_time, end_time, page_size, max_records): base_url = tenant.rstrip('/') endpoint = f"{base_url}/api/v2/events/data/alert" headers = { 'Netskope-Api-Token': token, 'Accept': 'application/json', 'User-Agent': 'GoogleSecOps-NetskopeAlertCollector/1.0' } records = [] newest_time = None page_num = 0 backoff = 1.0 start_epoch = to_epoch_seconds(start_time) end_epoch = to_epoch_seconds(end_time) operation_id = None url = f"{endpoint}?limit={page_size}&starttime={start_epoch}&endtime={end_epoch}" while True: page_num += 1 if len(records) >= max_records: print(f"Reached max_records limit ({max_records})") break if operation_id: url = f"{endpoint}?limit={page_size}&operation={operation_id}" try: response = http.request('GET', url, headers=headers) 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 [], None data = json.loads(response.data.decode('utf-8')) page_results = data.get('result', []) if not page_results: print("No more results (empty page)") break print(f"Page {page_num}: Retrieved {len(page_results)} alerts") records.extend(page_results) for event in page_results: try: event_time = event.get('timestamp') if event_time: if newest_time is None or event_time > newest_time: newest_time = event_time except Exception as e: print(f"Warning: Could not parse event time: {e}") wait_time = data.get('wait_time') operation_id = data.get('operation') if not operation_id or len(page_results) < page_size: break if wait_time and wait_time > 0: time.sleep(wait_time) except Exception as e: print(f"Error fetching alerts: {e}") return [], None print(f"Retrieved {len(records)} total records from {page_num} pages") return records, newest_time- requirements.txt:
functions-framework==3.* google-cloud-storage==2.* urllib3>=2.0.0[デプロイ] をクリックして関数を保存し、デプロイします。
Cloud Scheduler ジョブの作成
- Google Cloud コンソールで、[Cloud Scheduler] に移動します。
- [ジョブを作成] をクリックします。
次の構成情報を提供してください。
設定 値 名前 netskope-alerts-collector-hourlyリージョン Cloud Run functions の関数と同じリージョンを選択します。 周波数 0 * * * *(1 時間ごと、毎正時)タイムゾーン タイムゾーンを選択(UTC を推奨) ターゲット タイプ Pub/Sub トピック netskope-alerts-triggerを選択メッセージ本文 {}[作成] をクリックします。
Google SecOps でフィードを構成する
- [設定] > [データ管理] > [フィード] に移動します。SIEM のみのプラットフォームを使用している場合は、[設定] > [フィード] に移動します。
- [Add New Feed] > [Configure a single feed] をクリックします。
- フィード名:
Netskope Alerts。 - ソースタイプ: Google Cloud Storage V2。
- ログタイプ: Netskope Alert。
- [サービス アカウントを取得] をクリックし、表示されたメールアドレスをコピーします。
- [次へ] をクリックします。
- ストレージ バケットの URL:
gs://netskope-alerts-logs/netskope/alerts/(末尾のスラッシュを含む)。 - Source deletion option: 必要に応じて選択します(例: テストの場合は [Never])。
- [次へ] をクリックして確認し、[送信] をクリックします。
Google SecOps サービス アカウントに IAM 権限を付与する
- [Cloud Storage] > [バケット] に移動します。
netskope-alerts-logsをクリックします。- [権限] タブに移動します。
- [アクセス権を付与] をクリックします。
- プリンシパルを追加: Google SecOps サービス アカウントのメールアドレスを貼り付けます。
- ロールを割り当てる: [Storage オブジェクト閲覧者] を選択します。(フィードで削除オプションを使用する場合は、Storage オブジェクト管理者を使用します)。
- [保存] をクリックします。
UDM マッピング テーブル
| ログフィールド | UDM マッピング | ロジック |
|---|---|---|
app_activity_label |
additional.fields |
統合済み |
count_label |
additional.fields |
統合済み |
object_field |
additional.fields |
統合済み |
object_id_field |
additional.fields |
統合済み |
object_type_field |
additional.fields |
統合済み |
publisher_cn_field |
additional.fields |
統合済み |
publisher_name_field |
additional.fields |
統合済み |
site_label |
additional.fields |
統合済み |
tunnel_id_field |
additional.fields |
統合済み |
tunnel_type_field |
additional.fields |
統合済み |
access_method |
extensions.auth.auth_details |
直接マッピングされます。 |
accessmethod |
extensions.auth.auth_details |
result != `` の場合にマッピングされます。 |
activity |
extensions.auth.type |
マッピング済み: Login Failed → MACHINE、Login Successful → MACHINE、Login Attempt → MACHINE |
published |
metadata.event_timestamp |
RFC 3339 として解析 |
timestamp |
metadata.event_timestamp |
RFC 3339 として解析 |
Protocol |
metadata.event_type |
マッピング済み: HTTP → NETWORK_HTTP |
activity |
metadata.event_type |
マッピング済み: Introspection Scan → EMAIL_UNCATEGORIZED、Login Failed → USER_LOGIN、「Login ... |
has_principal |
metadata.event_type |
マッピング済み: true → NETWORK_HTTP、true → NETWORK_CONNECTION |
Id |
metadata.product_log_id |
result != `` の場合にマッピングされます。 |
_id |
metadata.product_log_id |
直接マッピングされます。 |
protocol |
network.application_protocol |
名前変更 / マッピング |
from_user |
network.email.from |
直接マッピングされます。 |
useridemail |
network.email.to |
マッピング済み: @ → useridemail |
user_agent |
network.http.parsed_user_agent |
名前変更 / マッピング |
useragent |
network.http.parsed_user_agent |
名前変更 / マッピング |
browser_version |
network.http.parsed_user_agent.browser_version |
直接マッピングされます。 |
browserversion |
network.http.parsed_user_agent.browser_version |
result != `` の場合にマッピングされます。 |
page |
network.http.referral_url |
直接マッピングされます。 |
referer |
network.http.referral_url |
名前変更 / マッピング |
Browser |
network.http.user_agent |
result != `` の場合にマッピングされます。 |
browser |
network.http.user_agent |
直接マッピングされます。 |
user_agent |
network.http.user_agent |
直接マッピングされます。 |
useragent |
network.http.user_agent |
直接マッピングされます。 |
ip_protocol_out |
network.ip_protocol |
直接マッピングされます。 |
server_bytes |
network.received_bytes |
名前変更 / マッピング |
client_bytes |
network.sent_bytes |
名前変更 / マッピング |
browserSessionid |
network.session_id |
result != `` の場合にマッピングされます。 |
browser_sess |
network.session_id |
名前変更 / マッピング |
network_session_id |
network.session_id |
名前変更 / マッピング |
ja3 |
network.tls.client.ja3 |
直接マッピングされます。 |
ja3s |
network.tls.server.ja3s |
直接マッピングされます。 |
netskope_pop |
observer.hostname |
直接マッピングされます。 |
organization_unit |
principal.administrative_domain |
直接マッピングされます。 |
Host |
principal.asset.hostname |
result != `` の場合にマッピングされます。 |
hostname |
principal.asset.hostname |
直接マッピングされます。 |
instance_id |
principal.asset.hostname |
直接マッピングされます。 |
srcIP |
principal.asset.ip |
統合済み |
srcip |
principal.asset.ip |
統合済み |
Host |
principal.hostname |
result != `` の場合にマッピングされます。 |
hostname |
principal.hostname |
直接マッピングされます。 |
instance_id |
principal.hostname |
直接マッピングされます。 |
srcIP |
principal.ip |
統合済み |
srcip |
principal.ip |
統合済み |
src_location |
principal.location.city |
名前変更 / マッピング |
src_country |
principal.location.country_or_region |
名前変更 / マッピング |
srccountry |
principal.location.country_or_region |
result != `` の場合にマッピングされます。 |
src_region |
principal.location.name |
名前変更 / マッピング |
srcregion |
principal.location.name |
result != `` の場合にマッピングされます。 |
srclatitude |
principal.location.region_coordinates.latitude |
名前変更 / マッピング |
srclongitude |
principal.location.region_coordinates.longitude |
名前変更 / マッピング |
src_latitude |
principal.location.region_latitude |
名前変更 / マッピング |
src_longitude |
principal.location.region_longitude |
名前変更 / マッピング |
os |
principal.platform |
マッピング済み: (?i)Windows → WINDOWS、(?i)MAC → MAC、(?i)LINUX → LINUX |
os_version |
principal.platform_version |
名前変更 / マッピング |
osversion |
principal.platform_version |
result != `` の場合にマッピングされます。 |
srcport |
principal.port |
名前変更 / マッピング |
from_user_category_label |
principal.resource.attribute.labels |
統合済み |
Device |
principal.resource.resource_subtype |
result != `` の場合にマッピングされます。 |
device |
principal.resource.resource_subtype |
直接マッピングされます。 |
User |
principal.user.email_addresses |
統合済み |
matched_username |
principal.user.email_addresses |
統合済み |
user |
principal.user.email_addresses |
統合済み |
user |
principal.user.userid |
名前変更 / マッピング |
_security_result |
security_result |
統合済み |
security_result1 |
security_result |
統合済み |
app |
target.application |
名前変更 / マッピング |
appName |
target.application |
result != `` の場合にマッピングされます。 |
domain |
target.asset.hostname |
直接マッピングされます。 |
dstIP |
target.asset.ip |
統合済み |
dst_ip |
target.asset.ip |
統合済み |
dstip |
target.asset.ip |
統合済み |
dlp_file |
target.file.full_path |
直接マッピングされます。 |
file_path |
target.file.full_path |
直接マッピングされます。 |
md5 |
target.file.md5 |
名前変更 / マッピング |
file_type |
target.file.mime_type |
直接マッピングされます。 |
sha256 |
target.file.sha256 |
名前変更 / マッピング |
file_size |
target.file.size |
名前変更 / マッピング |
domain |
target.hostname |
直接マッピングされます。 |
dstIP |
target.ip |
統合済み |
dst_ip |
target.ip |
統合済み |
dstip |
target.ip |
統合済み |
dst_location |
target.location.city |
名前変更 / マッピング |
dst_country |
target.location.country_or_region |
名前変更 / マッピング |
dstcountry |
target.location.country_or_region |
result != `` の場合にマッピングされます。 |
dst_region |
target.location.name |
名前変更 / マッピング |
dstregion |
target.location.name |
result != `` の場合にマッピングされます。 |
dstlatitude |
target.location.region_coordinates.latitude |
名前変更 / マッピング |
dstlongitude |
target.location.region_coordinates.longitude |
名前変更 / マッピング |
dstport |
target.port |
名前変更 / マッピング |
app_session_label |
target.resource.attribute.labels |
統合済み |
to_user_category_label |
target.resource.attribute.labels |
統合済み |
Url |
target.url |
result != `` の場合にマッピングされます。 |
url |
target.url |
名前変更 / マッピング |
to_user |
target.user.email_addresses |
マッピング済み: ^.+@.+$ → touser |
touser |
target.user.email_addresses |
マッピング済み: ^.+@.+$ → touser |
| なし | extensions.auth.type |
定数: MACHINE |
| なし | metadata.event_type |
定数: GENERIC_EVENT |
| なし | metadata.product_name |
定数: Netskope Alert |
| なし | metadata.vendor_name |
定数: Netskope |
| なし | network.http.parsed_user_agent.family |
定数: USER_DEFINED |
| なし | principal.platform |
定数: WINDOWS |
| なし | principal.resource.type |
定数: DEVICE |
| なし | target.asset.hostname |
定数: dsthost |
| なし | target.hostname |
定数: dsthost |
action |
security_result.action_details |
変更履歴からマッピング |
dlp_rule_severity |
security_result.severity |
変更履歴からマッピング |
useragent" and "user_agent |
network.http.user_agent |
変更履歴からマッピング |
traffic_type |
security_result.detection_fields |
変更履歴からマッピング |
device |
principal.resource.resource_sub_type |
変更履歴からマッピング |
type |
security_result.detection_fields |
変更履歴からマッピング |
app_session_id |
target.resource.attribute.labels |
変更履歴からマッピング |
malware_severity |
security_result.severity |
変更履歴からマッピング |
malware_type |
security_result.detection_fields |
変更履歴からマッピング |
threat_match_field |
security_result.detection_fields |
変更履歴からマッピング |
cci", "ccl |
additional.fields |
変更履歴からマッピング |
dlp_profile |
security_result.rule_type |
変更履歴からマッピング |
dlp_rule |
security_result.rule_name |
変更履歴からマッピング |
security_result.alert_state |
ALERTING |
変更履歴からマッピング |
security_result.alert_state |
NOT_ALERTING |
変更履歴からマッピング |
security_result.alert_state |
UNSPECIFIED |
変更履歴からマッピング |
変更ログ
さらにサポートが必要な場合 コミュニティ メンバーや Google SecOps のプロフェッショナルから回答を得ることができます。