流式引入 HTTP 请求

请求谓词和资源

操作 HTTP 谓词 HTTP 资源
引入 POST /v1/rest/ingest/{database}/{table}?{additional parameters}

请求参数

参数 说明 必需/可选
{database} 引入请求的目标数据库名称 必须
{table} 引入请求的目标表名称 必须

其他参数

其他参数的格式为 URL 查询 {name}={value} 对(以“&”字符分隔)。

参数 说明 必需/可选
streamFormat 指定请求正文中数据的格式。 值应为以下项之一:CSVTSVSCsvSOHsvPSVJSONMultiJSONAvro。 有关详细信息,请参阅支持的数据格式 必须
mappingName 表上定义的预创建引入映射的名称。 有关详细信息,请参阅数据映射。 管理表上预创建映射的方法在此处进行了说明。 可选,但如果 streamFormatJSONMultiJSONAvro 之一,则是必需的

例如,若要将 CSV 格式的数据引入到数据库 Test 中的表 Logs,请使用:

POST https://help.chinaeast2.kusto.chinacloudapi.cn/v1/rest/ingest/Test/Logs?streamFormat=Csv HTTP/1.1

若要使用预创建的映射 mylogmapping 引入 JSON 格式的数据,请使用:

POST https://help.chinaeast2.kusto.chinacloudapi.cn/v1/rest/ingest/Test/Logs?streamFormat=Json&mappingName=mylogmapping HTTP/1.1

请求标头

下表包含用于查询和管理操作的常用标头。

标准标头 说明 必需/可选
Accept 将此值设为 application/json 可选
Accept-Encoding 支持的编码为 gzipdeflate 可选
Authorization 请参阅身份验证 必须
Connection 启用 Keep-Alive 可选
Content-Length 在已知时指定请求正文长度。 可选
Content-Encoding 设为 gzip,但是正文必须经过 gzip 压缩 可选
Expect 设置为 100-Continue 可选
Host 设为已向其发送请求的域名(如 help.chinaeast2.kusto.chinacloudapi.cn)。 必须

下表包含用于查询和管理操作的常用自定义标头。 除非另有说明,否则这些标头仅用于遥测目的,而不会影响功能。

自定义标头 说明 必需/可选
x-ms-app 发出请求的应用程序的(易记)名称。 可选
x-ms-user 发出请求的用户的(易记)名称。 可选
x-ms-user-id x-ms-user 相同。 可选
x-ms-client-request-id 请求的唯一标识符。 可选
x-ms-client-version 发出请求的客户端的(易记)版本标识符。 在用于标识请求的场景(例如,取消正在运行的查询)中是必需的。 可选/必需

正文

正文是要引入的实际数据。 文本格式应使用 UTF-8 编码。

示例

以下示例演示了引入 JSON 内容的 HTTP POST 请求:

POST https://help.chinaeast2.kusto.chinacloudapi.cn/v1/rest/ingest/Test/Logs?streamFormat=Json&mappingName=mylogmapping HTTP/1.1

请求标头:

Authorization: Bearer ...AzureActiveDirectoryAccessToken...
Accept-Encoding: deflate
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 161
Host: help.chinaeast2.kusto.chinacloudapi.cn
x-ms-client-request-id: MyApp.Ingest;5c0656b9-37c9-4e3a-a671-5f83e6843fce
x-ms-user-id: alex@contoso.com
x-ms-app: MyApp

请求正文:

{"Timestamp":"2018-11-14 11:34","Level":"Info","EventText":"Nothing Happened"}
{"Timestamp":"2018-11-14 11:35","Level":"Error","EventText":"Something Happened"}

以下示例演示了引入相同压缩数据的 HTTP POST 请求。

POST https://help.chinaeast2.kusto.chinacloudapi.cn/v1/rest/ingest/Test/Logs?streamFormat=Json&mappingName=mylogmapping HTTP/1.1

请求标头:

Authorization: Bearer ...AzureActiveDirectoryAccessToken...
Accept-Encoding: deflate
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 116
Content-Encoding: gzip
Host: help.chinaeast2.kusto.chinacloudapi.cn
x-ms-client-request-id: MyApp.Ingest;5c0656b9-37c9-4e3a-a671-5f83e6843fce
x-ms-user-id: alex@contoso.com
x-ms-app: MyApp

请求正文:

... binary data ...