文档

导出到任意 HTTPS 端点

签名的 NDJSON 批次,可发送到您自己的采集端、Vector、Logstash、Cribl,或为 Microsoft Sentinel 供数的 Azure Function。

ModelRiver 发送的内容

HTTP
1POST /ingest HTTP/1.1
2Content-Type: application/x-ndjson
3Authorization: Bearer <token> (仅在设置了令牌时)
4X-ModelRiver-Timestamp: 1795600800
5X-ModelRiver-Signature: 5d41402abc4b2a76b9719d911017c592...
6X-ModelRiver-Batch-Id: 0193a4f2-..._0193a4f3-...
7 
8{"id":"0193a4f2-...","inserted_at":"2026-11-25T10:00:00.123456Z","action":"security.admin_key_created",...}
9{"id":"0193a4f3-...","inserted_at":"2026-11-25T10:00:01.002000Z","action":"data.audit_export_updated",...}

请求体是 NDJSON:每行一个事件对象,每行以换行符结尾。每批最多 500 个事件、1 MB。

您的端点必须:

  • 在保存批次后返回 2xx。返回 408、429 或 5xx 会让批次稍后重试,可附带 Retry-After: <秒数>。其他任何状态都被视为配置错误,不会重试。
  • 在 60 秒内响应。
  • 不重定向。从不跟随重定向。
  • 使用 HTTPS 和公共证书颁发机构签发的证书,主机解析到公网地址。

请用签名方法验证每个请求,并按事件 id 去重。

配置导出

在 Organization settings → Audit log export 中选择 Generic HTTPS / Sentinel,填写 Endpoint URL,并可选填写 Bearer token。保存后复制签名密钥:它只显示一次。然后选择 Send test。

如果修改了 URL 且令牌留空,已保存的令牌会被删除,因此它永远不会被发送到新的 URL。

页面会向组织管理员显示该 URL。不要在 URL 中放入机密:请使用 Bearer 令牌,或依靠签名。

Microsoft Sentinel

Sentinel 的 Logs Ingestion API 需要 Microsoft Entra 访问令牌,因此 ModelRiver 无法直接向它发送。请在前面放一个小型 Azure Function。该函数验证 ModelRiver 的签名,再用其托管标识转发事件。

以下步骤均未测试:

  1. 在 Azure Monitor 中创建数据收集终结点、Sentinel 工作区中的自定义表(如 ModelRiverAudit_CL),以及把事件字段映射到该表的数据收集规则(DCR)。添加一个由 inserted_at 计算的 TimeGenerated 列。
  2. 创建一个启用系统分配托管标识的 Python Azure Function 应用。在 DCR 上为该标识授予 Monitoring Metrics Publisher 角色。
  3. 添加一个 authLevel 为 anonymous 的 HTTP 触发函数:由签名来认证 ModelRiver。把签名密钥以 MODELRIVER_SIGNING_SECRET 存入应用设置,同时设置 DCE_ENDPOINT、DCR_IMMUTABLE_ID 和 DCR_STREAM(例如 Custom-ModelRiverAudit_CL)。
PYTHON
1import hashlib
2import hmac
3import json
4import os
5import time
6 
7import azure.functions as func
8from azure.identity import DefaultAzureCredential
9from azure.monitor.ingestion import LogsIngestionClient
10 
11app = func.FunctionApp()
12client = LogsIngestionClient(os.environ["DCE_ENDPOINT"], DefaultAzureCredential())
13 
14 
15@app.route(route="modelriver-audit", methods=["POST"], auth_level=func.AuthLevel.ANONYMOUS)
16def modelriver_audit(req: func.HttpRequest) -> func.HttpResponse:
17 body = req.get_body()
18 timestamp = req.headers.get("x-modelriver-timestamp", "0")
19 signature = req.headers.get("x-modelriver-signature", "")
20 expected = hmac.new(
21 os.environ["MODELRIVER_SIGNING_SECRET"].encode(),
22 timestamp.encode() + b"." + body,
23 hashlib.sha256,
24 ).hexdigest()
25 if abs(time.time() - int(timestamp)) > 300 or not hmac.compare_digest(expected, signature):
26 return func.HttpResponse(status_code=401)
27 
28 events = [json.loads(line) for line in body.splitlines() if line]
29 client.upload(rule_id=os.environ["DCR_IMMUTABLE_ID"], stream_name=os.environ["DCR_STREAM"], logs=events)
30 return func.HttpResponse(status_code=204)
  1. 在 ModelRiver 中把函数 URL(https://<app>.azurewebsites.net/api/modelriver-audit)填为 Endpoint URL,不填令牌。

如果 upload 抛出异常,函数返回 500,ModelRiver 会重试该批次。在 KQL 中去重可使用 ModelRiverAudit_CL | summarize arg_max(TimeGenerated, *) by id。

其他采集端

任何通过 HTTPS 接收 NDJSON 的系统都可以使用,例如 Vector 的 http_server 源、Logstash 的 http 输入或 Cribl 的 HTTP 源。如果采集端本身无法验证签名,请在转换步骤或代理中验证。