I have a use case where I’m trying to determine average amount of activity logs per day for specific users. My query gives me a compilation when using both avg() and count() functions in the outcome section.
My current query is
// 1. Calculate the day of the month for grouping
$day_of_month = timestamp.get_date(udm.metadata.event_timestamp.seconds)
// 2. Calculate the day of the week (1=Sunday, 7=Saturday)
$day_of_week_num = timestamp.get_day_of_week(udm.metadata.event_timestamp.seconds)
// 3. Filter for working days (Monday through Friday)
$day_of_week_num >= 2 and $day_of_week_num <= 6
// Log source filters
udm.metadata.log_type = "AZURE_AD" or udm.metadata.log_type = "UMBRELLA_DNS" or udm.metadata.log_type = "SLACK_AUDIT" or udm.metadata.log_type = "SALESFORCE" or udm.metadata.log_type = "WORKSPACE_ACTIVITY" or udm.metadata.log_type = "CS_EDR" or udm.metadata.log_type = "AWS_CLOUDTRAIL"
$log_source = udm.metadata.log_type
user=”...”
match:
// Group the logs by the day of the week
$day_of_week_num, $log_source
outcome:
// Count the total events for that specific date
$event_count = count(udm.metadata.id)
//$avg = avg($event_count)
order:
$day_of_week_num asc
If I have $avg=avg($event_count) I get the compilation error “aggregation cannot refer to outcome variables or contain another aggregation line”.
Please could I get some help with this.




