Representing data as cumulative bar chart

Gueorguiev, Orlin /Extern 21 Reputation points
2022-12-12T14:25:04.077+00:00

My data looks as following:
{
"data" : [{
"salesforceEntity": "Entity 1",
"state": "RUNNING",
"sumOfAllEntities": 299
},
{
"salesforceEntity": "Entity 2",
"state": "RUNNING",
"sumOfAllEntities": 103
},
{
"salesforceEntity": "Entity 2",
"state": "OPEN",
"sumOfAllEntities": 22
}]
}

What I would like to achieve is to represent data in a timeseries cumulative bar chart by state, as follows:
at <TimeGenerated>
salesforceEntity = "Entity 1"
state="OPEN"
sumOfAllEntities=22
state="RUNNING",
sumOfAllEntities=299

salesforceEntity="Entity 2"
state="RUNNING",
sumOfAllEntities=103

How can I do that?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Clive Watson 7,946 Reputation points MVP Volunteer Moderator
    2022-12-13T11:05:23.497+00:00

    This is a example (so you will need to tweak it ). You need from the mv-expand line onwards, pasted into your query.

    let ParsedMessageLog= dynamic(  
     {  
     "data" : [{  
     "salesforceEntity": "Entity 1",  
     "state": "RUNNING",  
     "sumOfAllEntities": 299  
     },  
     {  
     "salesforceEntity": "Entity 2",  
     "state": "RUNNING",  
     "sumOfAllEntities": 103  
     },  
     {  
     "salesforceEntity": "Entity 2",  
     "state": "OPEN",  
     "sumOfAllEntities": 22  
     }]  
     }  
    );  
    print a=ParsedMessageLog.data  
    | mv-expand a  
    | extend salesforceEntity_ = tostring(a.salesforceEntity)  
    | extend state_ = tostring(a.state)  
    | extend sumOfAllEntities_ = toint(a.sumOfAllEntities)  
    | project-away a  
    | summarize sum(sumOfAllEntities_) by salesforceEntity_  
    

    https://portal.azure.com#@d8ee6e2f-3e07-4558-b301-610427e94492/blade/Microsoft_Azure_Monitoring_Logs/DemoLogsBlade/aiDemo/true/resourceId/%2FDemo/source/LogsBlade.AnalyticsShareLinkToQuery/q/H4sIAAAAAAAAA52QTUvDQBCG7%252Fsrhj0l0BYbT63k4KGIoGkRPInINJmGlXyxO62NH%252F%252FdneZStlioh4X5eOadd6cihhVaR8UjOYclPbRlCkXfYG3ySMGXAl0go4Y5vEjisCK3aW1Oi4YN93oOeohgqkcCMDJJ9ek5y%252B6zu6G4rZeb26o6kIac7yezmYKf0bDijGpyker06vo%252FqsvVIvvTaOIVX%252F1T8Y3qrGkYMA1vNpEjqW%252Bod2Pad9gUIBntmXwY%252BniDFLh17LXKCCdhOz6aFIMhLrVjJrA84N6msEFPxjrbvlPOY%252FzA%252FuDSQzVa80kSRSdyMaz70y%252F8AvYeZ7Y5AgAA/timespan/P1D

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Clive Watson 7,946 Reputation points MVP Volunteer Moderator
    2022-12-12T17:40:17+00:00

    Do you mean this?

    datatable (TimeGenerated:datetime, salesforceEntity:string, state:string,sumOfAllEntities:int )   
    [   
     "2022-12-11","Entity 1","RUNNING",299,  
     "2022-12-12","Entity 2", "RUNNING",103,  
     "2022-12-12","Entity 2", "RUNNING",2  
    ]  
    | summarize sum(sumOfAllEntities) by salesforceEntity, TimeGenerated  
    | render columnchart   
    

    Please "accept" if this helps


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.