kusto函数来解析为数字的json

问题描述 投票:0回答:1

我无法解析下面的json值,我尝试使用parse_json()和todynamic(),我将结果列的值设置为空

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS91SGFPOC5wbmcifQ==” alt =“在此处输入图像描述”>] 1

{“ pipelineId”:“ 63dfc1f6-5a43-5bca-bffe-6a36a435e19d”,“ vmId”:“ 9252382a-814f-4d02-9b1b-305db4caa208 / usl-exepipe-dev / westus / usl-exepipe-lab-dev / asuvp306563“,” artifactResult“:{” Id“:” execution-job-2“,” SourceName“:” USL存储库“,” ArtifactName“:” install-lcu“,” Status“:”成功“,” Parameters“ :null,“ Log”:“ [{\” code \“:\” ComponentStatus / StdOut / succeeded \“,\” level \“:\” Info \“,\” displayStatus \“:\\”配置成功\“ ,\“ message \”:\“ 2020-06-02T14:33:04.711Z |我启动工件'install-lcu'\ r \ n2020-06-02T14:33:04.867Z |我正在开始安装\ r \ n2020-06-02T14:33:04.899Z |我C:\\ USL \\ LCU \\ 4556803.msu存在。\ r \ n2020-06-02T14:33:04.914Z |我开始安装过程'C:\\ USL \\ LCU \\ 4556803.msu / quiet /norestart'\r\n2020-06-02T14:43:14.169Z |我流程已完成,退出代码为“ 3010” \ r \ n2020-06-02T14:43:14.200Z |我安装修补程序4556803后需要重新启动计算机\ r \ n2020-06-02T14:43:14.200Z |我完成安装\ r \ n2020-06-02T14:43:14.200Z |我工件'install-lcu'成功\ r \ n \“,\” time \“:null},{\” code \“:\” ComponentStatus / StdErr / succeeded \“,\” level \“:\” Info \ “,\” displayStatus \“:\”预配置成功\“,\”消息\“:\” \“,\” time \“:null}]”,“ DeploymentLog”:null,“ StartTime”:“ 2020- 06-02T14:32:40.9882134Z“,” ExecutionTime“:” 00:11:21.2468597“,” BSODCount“:0},”尝试“:1,” instanceId“:” a301aaa0c2394e76832867bfeec04b5d:0“,” parentInstanceId“:” 78d0b036a5c548ecaafc5e47dcc76ee4:2“,” eventName“:”工件结果“}

azure-application-insights kusto
1个回答
0
投票

问题是您的有效负载包括内部无效的JSON有效负载。可以使用查询语言来“修复”它(请参见下面的示例中的replace()的用法),但是最好是可以编写一个有效的JSON负载作为开始。

尝试运行此:

print s = @'{"pipelineId":"63dfc1f6-5a43-5bca-bffe-6a36a435e19d","vmId":"9252382a-814f-4d02-9b1b-305db4caa208/usl-exepipe-dev/westus/usl-exepipe-lab-dev/asuvp306563","artifactResult":{"Id":"execution-job-2","SourceName":"USL Repository","ArtifactName":"install-lcu","Status":"Succeeded","Parameters":null,"Log":"[{\"code\":\"ComponentStatus/StdOut/succeeded\",\"level\":\"Info\",\"displayStatus\":\"Provisioning succeeded\",\"message\":\"2020-06-02T14:33:04.711Z | I | Starting artifact ''install-lcu''\r\n2020-06-02T14:33:04.867Z | I | Starting Installation\r\n2020-06-02T14:33:04.899Z | I | C:\\USL\\LCU\\4556803.msu Exists.\r\n2020-06-02T14:33:04.914Z | I | Starting installation process ''C:\\USL\\LCU\\4556803.msu /quiet /norestart''\r\n2020-06-02T14:43:14.169Z | I | Process completed with exit code ''3010''\r\n2020-06-02T14:43:14.200Z | I | Need to restart computer after hotfix 4556803 installation\r\n2020-06-02T14:43:14.200Z | I | Finished Installation\r\n2020-06-02T14:43:14.200Z | I | Artifact ''install-lcu'' succeeded\r\n\",\"time\":null},{\"code\":\"ComponentStatus/StdErr/succeeded\",\"level\":\"Info\",\"displayStatus\":\"Provisioning succeeded\",\"message\":\"\",\"time\":null}]","DeploymentLog":null,"StartTime":"2020-06-02T14:32:40.9882134Z","ExecutionTime":"00:11:21.2468597","BSODCount":0},"attempt":1,"instanceId":"a301aaa0c2394e76832867bfeec04b5d:0","parentInstanceId":"78d0b036a5c548ecaafc5e47dcc76ee4:2","eventName":"Artifact Result"}'
| mv-expand log = parse_json(replace("\r\n", " ", replace(@"\\", @"\\\\", tostring(parse_json(tostring(parse_json(s).artifactResult)).Log))))
| project log.code, log.level, log.displayStatus, log.message
© www.soinside.com 2019 - 2024. All rights reserved.