从大型 json 文件摄取到 kusto 从 blob - 扩展对象数组

问题描述

我正在尝试将 json 文件摄取到 kusto(.zip 文件)中,并使用更新策略进一步处理 json

Approach 1 :file has following contents

{
  "id": "id0","logs": [
    {
      "timestamp": "2021-05-26T11:33:26.182Z","message": "test message 1"
    },{
      "timestamp": "2021-05-26T11:33:26.182Z","message": "test message 1"
    }
  ]
}

.create table test (
  logs : dynamic
)

.create-or-alter table test ingestion json mapping 'testmapping'
'['
'{"column":"logs","path":"$.logs","datatype":"","transform":"None"}'
']'

.ingest into table test(
  h@"sasUrlfromazureBlob"
)
with (
  format = "multijson",ingestionMappingReference = "testmapping",zipPattern = "*"
)

以上是在一行中摄取整个日志数组,但我希望将其扩展为多行

方法二:

Input file conatains:

[
    {
      "timestamp": "2021-05-26T11:33:26.182Z","message": "test message 1"
    }
]

.create table test (
  logs : dynamic
)

.create-or-alter table test ingestion json mapping 'testmapping'
'['
'{"column":"logs","path":"$","transform":"None"}'
']'

上面很好地将日志扩展为多行(本例中为 2 行) 但是当我从对象(方法 1)中选择数组时,它会转储到单行中,问题是,动态数据类型的数据限制为 1MB

解决方法

如果问题是从选项 #1 中的输入数据转换为选项 #2 中的所需数据,您应该使用外部服务进行转换,例如,读取格式为 # 的数据的 Azure 函数1 并将其写为 #2。

附带说明,使用选项 #2,您会丢失“id”属性。