Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i perform a distinct statement in azure applications insights?

I have a query that pulls a list of user engements of the form: Date, user name, campaign_id,

There is uniqueness in the campaign_id in a sense that a user clicks only once per day per campaign_id (campaign id cant be logged twice for the same user within a day)

My question is how do I pull a list of unique active users per month? A user can be logged more than once for different campaigns and different days.

customEvents 
| extend rTimeStamp = todatetime(customDimensions.timeStamp), 
         username = tolower(tostring(customDimensions.username)), 
         event = name, item_uid = tostring(customDimensions.itemId) 
| extend rTimeStamp = todatetime(substring(tostring(rTimeStamp), 0, 10)) 
| where event == 'click' 
| project rTimeStamp, username, event, item_uid
| summarize arg_min(rTimeStamp, *) by item_uid, username 
| summarize click_count = countif(event == 'click') by rTimeStamp, username, item_uid 
| order by rTimeStamp
like image 686
Itay Holtzman Avatar asked May 29 '18 18:05

Itay Holtzman


People also ask

How do I get unique values in KQL?

Re: kql query for distinct values If that is not an issue then after you get your host and your displayName, you can concatenate (using the strcat command) and then perform another distinct on the concatenated string. Hope this is what you are looking for.

How do I use Azure application Insights?

Select Application Insights in the Azure control panel for your app service, then select Enable. Choose to create a new resource, or select an existing Application Insights resource for this application. When you click OK to create the new resource you will be prompted to Apply monitoring settings.


1 Answers

Using the "distinct" operator:

... 
| distinct username

If you'd like a list of distinct users per month, also possible with summarize:

...
| summarize by username, bin(rTimeStamp, 30d)
like image 153
Assaf Neufeld Avatar answered Oct 03 '22 04:10

Assaf Neufeld