Azure 数据资源管理器流摄取格式 JSON 文档
Azure Data Explorer Stream Ingest formatted JSON Documents
我们通过流摄取将事件中心的 JSON 消息摄取到 Azure 数据资源管理器中。
我用这个语句创建了一个table
.create table messages(SerialNumber: string, ReceivedUtcTime: datetime, IngestEventEnqueuedUtcTime: datetime, IngestEventProcessedUtcTime: datetime, ProcessEventEnqueuedUtcTime: datetime, MessageVersion: int, MessageType: string, Payload: dynamic)
使用此摄取映射:
.create-or-alter table messages ingestion json mapping "eventhub_mapping"
'['
'{"column":"SerialNumber", "path":"$.serialNumber", "datatype":"string" },'
'{"column":"ReceivedUtcTime", "path":"$.timestampUtc", "datatype":"datetime" },'
'{"column":"IngestEventEnqueuedUtcTime", "path":"$.eventEnqueuedUtcTime", "datatype":"datetime" },'
'{"column":"IngestEventProcessedUtcTime", "path":"$.eventProcessedUtcTime", "datatype":"datetime" },'
'{"column":"ProcessEventEnqueuedUtcTime", "path":"$.x-opt-enqueued-time", "datatype":"datetime" },'
'{"column":"MessageVersion", "path":"$.messageVersion", "datatype":"int" },'
'{"column":"MessageType", "path":"$.messageType", "datatype":"string" },'
'{"column":"Payload", "path":"$.payload", "datatype":"dynamic", "transform":null }'
']'
我们要接收的消息如下所示:
{
"timestampUtc": "2022-03-07T00:00:00Z",
"eventEnqueuedUtcTime": "2022-03-07T00:00:00Z",
"eventProcessedUtcTime": "2022-03-07T00:00:00Z",
"messageType": "Information",
"messageVersion": 1,
"serialNumber": "ser-1",
"payload": {
"TimestampUtc": "2022-03-07T00:00:00Z",
"Value": 123.12
}
}
当我尝试摄取这些消息时,我在摄取过程中遇到错误,table 中没有存储任何内容。
但是,我发现,如果我将 JSON 作为单行传输而不进行格式化,消息将按预期存储。
所以这条消息有效:
{"timestampUtc":"2022-03-07T00:00:00Z","eventEnqueuedUtcTime":"2022-03-07T00:00:00Z","eventProcessedUtcTime":"2022-03-07T00:00:00Z","messageType":"Information","messageVersion":1,"serialNumber":"ser-1","payload":{"TimestampUtc":"2022-03-07T00:00:00Z","Value":123.12}}
这是意料之中的事情吗?我可以配置此行为以允许将每个有效的 JSON 提取到 Data Explorer 中吗?
我已阅读有关 的选项,但在创建摄取映射时似乎不支持此选项。
我们通过流摄取将事件中心的 JSON 消息摄取到 Azure 数据资源管理器中。
我用这个语句创建了一个table
.create table messages(SerialNumber: string, ReceivedUtcTime: datetime, IngestEventEnqueuedUtcTime: datetime, IngestEventProcessedUtcTime: datetime, ProcessEventEnqueuedUtcTime: datetime, MessageVersion: int, MessageType: string, Payload: dynamic)
使用此摄取映射:
.create-or-alter table messages ingestion json mapping "eventhub_mapping"
'['
'{"column":"SerialNumber", "path":"$.serialNumber", "datatype":"string" },'
'{"column":"ReceivedUtcTime", "path":"$.timestampUtc", "datatype":"datetime" },'
'{"column":"IngestEventEnqueuedUtcTime", "path":"$.eventEnqueuedUtcTime", "datatype":"datetime" },'
'{"column":"IngestEventProcessedUtcTime", "path":"$.eventProcessedUtcTime", "datatype":"datetime" },'
'{"column":"ProcessEventEnqueuedUtcTime", "path":"$.x-opt-enqueued-time", "datatype":"datetime" },'
'{"column":"MessageVersion", "path":"$.messageVersion", "datatype":"int" },'
'{"column":"MessageType", "path":"$.messageType", "datatype":"string" },'
'{"column":"Payload", "path":"$.payload", "datatype":"dynamic", "transform":null }'
']'
我们要接收的消息如下所示:
{
"timestampUtc": "2022-03-07T00:00:00Z",
"eventEnqueuedUtcTime": "2022-03-07T00:00:00Z",
"eventProcessedUtcTime": "2022-03-07T00:00:00Z",
"messageType": "Information",
"messageVersion": 1,
"serialNumber": "ser-1",
"payload": {
"TimestampUtc": "2022-03-07T00:00:00Z",
"Value": 123.12
}
}
当我尝试摄取这些消息时,我在摄取过程中遇到错误,table 中没有存储任何内容。
但是,我发现,如果我将 JSON 作为单行传输而不进行格式化,消息将按预期存储。
所以这条消息有效:
{"timestampUtc":"2022-03-07T00:00:00Z","eventEnqueuedUtcTime":"2022-03-07T00:00:00Z","eventProcessedUtcTime":"2022-03-07T00:00:00Z","messageType":"Information","messageVersion":1,"serialNumber":"ser-1","payload":{"TimestampUtc":"2022-03-07T00:00:00Z","Value":123.12}}
这是意料之中的事情吗?我可以配置此行为以允许将每个有效的 JSON 提取到 Data Explorer 中吗?
我已阅读有关