I got to as far as a json result from log analytic query API HTTP action call:
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "_queue",
"type": "string"
},
{
"name": "_messages",
"type": "real"
}
],
"rows": [
[
"2022-06-03T03:20:00Z",
"queue1",
8073
],
[
"2022-06-03T03:20:00Z",
"queue2",
570
]
]
}
]
}
I need transform it to this following format, which essentially an adaptivecards.io
card
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "**TimeGenerated**" //Columns[0].Name
},
{
"type": "TextBlock",
"text": "2022-06-03T03:20:00Z" //Rows[0][0]
},
{
"type": "TextBlock",
"text": "2022-06-03T03:20:00Z" //Rows[1][0]
}
]
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "**_queue**" //Columns[1].Name
},
{
"type": "TextBlock",
"text": "queue1" //Rows[0][1]
},
{
"type": "TextBlock",
"text": "queue2" //Rows[1][1]
}
]
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "**_messages**"
},
{
"type": "TextBlock",
"text": "8073"
},
{
"type": "TextBlock",
"text": "570"
}
]
}
]
}
How can I do this? I tried with nested for-loop action, however I’m stuck in composing the final variable that can be inserted in the right place.
It would be ideal to hold a transformed variable ahead of time so that I can just include it in the later stage as POST to another webhook.
Edit: Whilst the column is static, the number rows are dynamic.
2
Answers
My own solution. Essentially it's broken down into two stages: Initialize the column header and then append the rows at 2nd stage.
Pseudo code
Full solution:
Create a LogicApp and load in this definition to see how to do it …
Basically, you just need to navigate to the specific section of the JSON to retrieve what you need for each individual value.
This is an example of what I’m talking about …
… that will get you to the
name
property for the second column in the first table.