如何使用Kusto的.ingest命令批量导入存储中的JSON文件至另一集群?
Kusto跨集群JSON文件导入解决方案
正确的.ingest命令写法
你之前的命令存在两个核心问题:
- 第一个命令未明确指定文件格式为JSON,Kusto无法自动识别解析规则
- 第二个命令使用了
*.ext通配符,与实际生成的.json文件后缀不匹配
修正后的标准命令如下:
.ingest into table VmCounterFiveMinuteRoleInstanceCentralBondTable_2 ( h@'https://contoso.blob.core.windows.net/oversub/adx/VmCounterFiveMinutes/2023-05-20/*.json;storage-account-access-key' ) with (format='json')
如果导出时定义了字段映射规则,可添加ingestMappingReference参数复用规则,避免字段解析错误:
.ingest into table VmCounterFiveMinuteRoleInstanceCentralBondTable_2 ( h@'https://contoso.blob.core.windows.net/oversub/adx/VmCounterFiveMinutes/2023-05-20/*.json;storage-account-access-key' ) with (format='json', ingestMappingReference='你的映射规则名称')
更优导入方案
1. 异步批量导入
针对192个文件的大规模导入,建议使用异步命令避免同步超时:
.ingest async into table VmCounterFiveMinuteRoleInstanceCentralBondTable_2 ( h@'https://contoso.blob.core.windows.net/oversub/adx/VmCounterFiveMinutes/2023-05-20/*.json;storage-account-access-key' ) with (format='json')
执行后会返回操作ID,可通过以下命令查询进度:
.show operations <操作ID>
2. 容器级路径导入
直接指定目标文件夹路径,Kusto会自动遍历路径下所有JSON文件,无需通配符:
.ingest into table VmCounterFiveMinuteRoleInstanceCentralBondTable_2 ( h@'https://contoso.blob.core.windows.net/oversub/adx/VmCounterFiveMinutes/2023-05-20/;storage-account-access-key' ) with (format='json')
3. 跨集群直接复制(跳过存储中转)
如果源集群与目标集群网络互通,直接用.copy命令跨集群复制,效率远高于导出再导入:
.copy into VmCounterFiveMinuteRoleInstanceCentralBondTable_2 from cluster('源集群名称').database('源数据库名称').VmCounterFiveMinuteRoleInstanceCentralBondTable_2 with (create_table=true)
内容的提问来源于stack exchange,提问作者Guilherme Matheus
相关产品推荐
相关产品推荐

