Robin Johansson
Robin Johansson

Reputation: 5

Need to add multiple application insights results in one query

is it possible to get the query to summarize from multiple Application insights? I cant get it working with Union command.

Example query:

union
app("applicationinsight02").requests, 
app("applicationinsight03").requests


availabilityResults
| where timestamp > ago(30d)
// check whether location failed within 5m bin
| summarize _failure=iff(countif(success == 0)>0, 1, 0) by name, location, bin(timestamp, 5m)
// check whether all locations failed within 5m bin
| summarize _failureAll=iff(sum(_failure)>=3, 1, 0) by name, bin(timestamp, 5m)
// count all failed 5 minute bins and total number of bins
| summarize _failuresCount=sum(_failureAll), _totalCount=count() by name
| project ["Name"] = name,            ["SLA"] = todouble(_totalCount - _failuresCount) / todouble(_totalCount) * 100
| order by ["SLA"]

Upvotes: 0

Views: 1627

Answers (1)

Dylan Morley
Dylan Morley

Reputation: 1726

Yes, something like so

union
app("application-insights-01").requests, 
app("application-insights-02").requests
| where timestamp > ago(1h)
| summarize sum(itemCount) by appName, bin(timestamp, 5m)

That will summarize the requests and show you the split by appname (the app insights resource name). Amend the where clause to fit your requirements

An example for availability results with your query would look like so, just replace application-insights-01/02 with your instance names

union
app("application-insights-01").availabilityResults, 
app("application-insights-02").availabilityResults
| where timestamp > ago(1h)
| summarize _failure=iff(countif(success == 0)>0, 1, 0) by name, location, bin(timestamp, 5m)
| summarize _failureAll=iff(sum(_failure)>=3, 1, 0) by name, bin(timestamp, 5m)
| summarize _failuresCount=sum(_failureAll), _totalCount=count() by name
| project ["Name"] = name, ["SLA"] = todouble(_totalCount - _failuresCount) / todouble(_totalCount) * 100
| order by ["SLA"]

Upvotes: 1

Related Questions