Gurudas
Gurudas

Reputation: 11

Need to prepare Kusto Query to show bar chart on azure dashboard

Currently, I am facing difficulty in constructing KQL to display a chart on our dashboard for the following requirements: Requirements Details : We're fetching log messages from Application Insights, which is a text as like "#TotalVM:15,Running:10,highcompute:5". This text contains Total VM count as 15, Running VM count as 10 and HightCompute VM count as 5. Based on this data we need to calculate Stopped VM count which is Total VM - Running VM. Similar for Non-HighCompute VM also. Now with this text we need to generate a graph through KQL which is shown a chart as given in this image .[Click on image link given here] enter image description here Any help for the same to prepare Kusto Query?

Upvotes: 0

Views: 253

Answers (1)

Balaji
Balaji

Reputation: 1768

Need to prepare Kusto Query to show bar chart on azure dashboard

Below query is used to show bar chart on Azure dashboard. In below query newTable consists of the data which is in text format. #TotalVM, Running and highcompute values are converted to int for calculating StoppedVMCount and NonHighComputeVMCount to view in the bar chart as shown below.

let newTable = datatable(LogMessage:string)
[
    "#TotalVM:15,Running:10,highcompute:5",
    "#TotalVM:20,Running:12,highcompute:8",
    "#TotalVM:18,Running:8,highcompute:6"
];

newTable
| extend TotalVMCount = toint(extract("(?i)#TotalVM:(\\d+)", 1, LogMessage)),
         RunningVMCount = toint(extract("(?i)Running:(\\d+)", 1, LogMessage)),
         HighComputeVMCount = toint(extract("(?i)highcompute:(\\d+)", 1, LogMessage))
| extend StoppedVMCount = TotalVMCount - RunningVMCount,
         NonHighComputeVMCount = TotalVMCount - HighComputeVMCount
| project StoppedVMCount, NonHighComputeVMCount

Output: enter image description here

Upvotes: 0

Related Questions