Reputation: 31
We have a custom event put in place on page which tracks the link clicks on given page to app insights. And with the REST API we would like to get the frequently accessed links from app insights. How can we build the Query to get this analytics data, any sample on reading custom events available?
Thanks
Upvotes: 0
Views: 1321
Reputation: 25168
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:
//What are the top 10 custom events of your application in the past 24 hours?
customEvents
| where timestamp >= ago(24h)
| summarize dcount(user_Id), count() by name
| top 10 by count_
| render barchart
which:
customEvents
, timestamp >= ago(24h)
), dcount(user_Id)
) and the total number of events (count()
), grouped by the event name (by name
), top 10 by count_
) 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.)
Upvotes: 2