if you open the Application Insights Analytics website for any resource, there's some "Common Queries" examples right on the front page. one of them is called "Usage" and if you click it it will show you this one:
customEvents
| where timestamp >= ago(24h)
| summarize dcount(user_Id), count() by name
| top 10 by count_
| render barchart
which:
- queries
customEvents
,
- filtering to the last 24 hours (
timestamp >= ago(24h)
),
- does a summary of the distinct count of users (
dcount(user_Id)
) and the total number of events (count()
), grouped by the event name (by name
),
- then filters to the top 10 by the _count field created from the summarization (
top 10 by count_
)
- and then renders it as a bar chart (
render barchart
)
there are many other examples on the analytics home page as well.
Edit to add: You can easily query any custom properties or metrics that you send as well. the customDimensions
and customMeasurements
fields in each event type are json
typed fields, and if there's no spaces in the names, you can just use dot notation to grab values. if the field has names/special characters, use brackets and quotes:
customEvents
| where timestamp >= ago(1h)
| extend a = customDimensions.NameOfFieldWithNoSpacesOrSpecialCharacters
| extend b = customDimensions["Field with spaces"]
| extend duration = customMeasurements["Duration (ms)"]
| project a, b, duration
| limit 10
(you don't need to use extend
, you can use the fields however you want this way, with extend
or project
or summarize
or any other functions or anything else. i just used extend
for the example here.)