所以我需要從查詢中的以下資料中提取一些子字串
[
{
"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"
}
}
]
在 grafana 中,顯然在桌子上放那么長的字串對我來說毫無用處。我需要以某種方式決議資料并提取每個網路鏈接末尾的數字以及“子”短語,并以某種方式將它們最好作為子列(或該位置的任何短語)與末尾的數字連接起來的網路鏈接是表中的資料。有人告訴我,我需要“撰寫一個回圈來遍歷 JSON”,任何幫助、建議、任何東西,都將不勝感激
注意:查詢拉出的每個專案的字串都不同,并且有幾千個
uj5u.com熱心網友回復:
mv-expand運算子,用于展開陣列。
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_url | 數 |
|---|---|
| https://fakelink/workItems/247155 | 247155 |
| https://fakelink/workItems/247154 | 247154 |
| https://fakelink/247160 | 247160 |
| https://fakelink/247156 | 247156 |
| https://fakelink/workItems/247159 | 247159 |
| https://fakelink/workItems/247157 | 247157 |
| https://fakelink/247158 | 247158 |
小提琴
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/495256.html
標籤:json 天蓝色 天蓝色的devops 格拉法纳 kql
上一篇:Azure迭代容器中的Blob
