循环通过查询以拉动KQL/Grafana中的子字样?

发布于 2025-02-09 16:48:21 字数 1511 浏览 2 评论 0原文

因此,我需要从Grafana中的查询中从以下数据中获取一些子字符串,

[
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247155",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247154 ",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/247160",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/247156",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247159",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247157",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/247158",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  }
]

这显然在表中有那根长字符串对我来说是没有用的。我需要以某种方式解析数据,并在每个Web链接的末尾以及“孩子”短语中拉出数字,并以某种方式将这些短语(或者选择为子列(或该位置上的任何短语))与末尾的数字连接起来网络链接是表中的数据。有人告诉我我需要“写一个循环以浏览JSON”,根本没有任何帮助,建议,任何内容,都会非常理解

:琴弦在每个项目中都不同,查询已拉起,有几千个。

So I need to pull the some substrings from the following data from a query

[
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247155",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247154 ",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/247160",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/247156",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247159",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/workItems/247157",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  },
  {
    "rel": "System.LinkTypes.Hierarchy-Forward",
    "url": "https://fakelink/247158",
    "attributes": {
      "isLocked": false,
      "name": "Child"
    }
  }
]

In grafana obviously having that long string in a table is useless to me. I need to somehow parse the data and pull the number at the end of each web link as well as the "Child" phrases and somehow connect those preferably as a Child column (or whatever phrase is in that spot) with the numbers at the end of the web links being the data in the table. I was told I needed to "write a loop to go through the JSON" any help at all, suggestions, anything, would be massively appreciated

note: the string is different for every single item the query pulled up and there's a couple thousand

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

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

发布评论

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

评论(1

痴情 2025-02-16 16:48:21

mv-expander阵列。
parse 操作员,以从每个URL。

datatable(doc:dynamic)[dynamic([ { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247155", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247154 ", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247160", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247156", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247159", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247157", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247158", "attributes": { "isLocked": false, "name": "Child" } } ])]
| mv-expand doc
| project doc.url
| parse doc_url with * "/" num:long
doc_urlhttps
:// fakelink/workitems/247155247155
https:// fakelink/workitems/247154247154
https:// fakelink/247159
fakelink/fakelink/247160 247160 247160
https:// 9https
: //fakelink/workItems/247157247157
https://fakelink/247158247158

mv-expand operator, to explode the array.
parse operator, to extract the number from each url.

datatable(doc:dynamic)[dynamic([ { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247155", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247154 ", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247160", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247156", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247159", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/workItems/247157", "attributes": { "isLocked": false, "name": "Child" } }, { "rel": "System.LinkTypes.Hierarchy-Forward", "url": "https://fakelink/247158", "attributes": { "isLocked": false, "name": "Child" } } ])]
| mv-expand doc
| project doc.url
| parse doc_url with * "/" num:long
doc_urlnum
https://fakelink/workItems/247155247155
https://fakelink/workItems/247154247154
https://fakelink/247160247160
https://fakelink/247156247156
https://fakelink/workItems/247159247159
https://fakelink/workItems/247157247157
https://fakelink/247158247158

Fiddle

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