如何从 splunk 中的转义 JSON(嵌套)中提取字段?

发布于 2025-01-15 18:03:27 字数 1061 浏览 0 评论 0原文

我正在寻求从 JSON 中提取“allowedSourceAddressPrefix”字段/值的帮助。该字段是嵌套 JSON 内的转义 JSON 字符串。以下是 JSON 树

- properties (extracted by splunk)
  - /subscription/..../.../  (dynamic field)
    - ports (escaped json)
      - allowedSourceAddressPrefix (nested json)

allowedSourceAddressPrefix 采用单个 ip 地址(或)多个 ip 地址(或)* 的值。

我尝试了各种雷克斯模式,但未能提取所需的字段,感谢任何帮助。 的 JSON

properties: {
  "User": "[email protected]",
  "/subscriptions/3483b2ca-02cf-4ff6-92af-99326c8fac7f/resourceGroups/apple-dev/providers/Microsoft.Compute/virtualMachines/gjappledev": "{\"id\":\"/subscriptions/3483b2ca-02cf-4ff6-92af-99326c8fac7f/resourceGroups/apple-dev/providers/Microsoft.Compute/virtualMachines/gjappledev\",\"ports\":[{\"number\":3389,\"allowedSourceAddressPrefix\":\"*\",\"endTimeUtc\":\"2022-03-21T1:50:39.1599446Z\"}]}",
  "Justification": null
}

以下是具有必填字段TIA

I'm looking for help in extracting "allowedSourceAddressPrefix" field/value from a JSON. This field is an escaped JSON string inside a nested JSON. Following is the JSON tree

- properties (extracted by splunk)
  - /subscription/..../.../  (dynamic field)
    - ports (escaped json)
      - allowedSourceAddressPrefix (nested json)

The allowedSourceAddressPrefix takes values of single ipaddress (or) multiple ip addresses (or) *.

I have tried various rex patterns but failed in extracting the required field, Any help is appreciated. Following is the JSON that has the required field

properties: {
  "User": "[email protected]",
  "/subscriptions/3483b2ca-02cf-4ff6-92af-99326c8fac7f/resourceGroups/apple-dev/providers/Microsoft.Compute/virtualMachines/gjappledev": "{\"id\":\"/subscriptions/3483b2ca-02cf-4ff6-92af-99326c8fac7f/resourceGroups/apple-dev/providers/Microsoft.Compute/virtualMachines/gjappledev\",\"ports\":[{\"number\":3389,\"allowedSourceAddressPrefix\":\"*\",\"endTimeUtc\":\"2022-03-21T1:50:39.1599446Z\"}]}",
  "Justification": null
}

TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然 2025-01-22 18:03:27

了解您尝试过的一些正则表达式会有所帮助,因此我们不再重复它们。

您是否尝试过使用 spath 命令来解析 JSON?

也许这个rex命令会有所帮助

| rex "allowedSourceAddressPrefix\\\\\":\\\\\"(?<allowedSourceAddressPrefix>[^\\\]+)"

It would help to know some of the regular expressions you've tried so we don't repeat them.

Have you tried the spath command to parse the JSON?

Perhaps this rex command will help

| rex "allowedSourceAddressPrefix\\\\\":\\\\\"(?<allowedSourceAddressPrefix>[^\\\]+)"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文