I'm trying to create a CloudWatch Insights query for Amazon Connect that will give me call counts by date. I'm able to get the number of log messages by date, however, I need to only count unique ContactId's. The query I have has many duplicated ContactId's since each time Connect logs to CloudWatch, it uses ContactId to tie all of the events related to a contact together. Is there a way to modify this query to only show the count of the unique ContactId?

filter @message like /ContactId/ | stats count(*) as callCount by toMillis(datefloor(1d)) | sort callCount desc 

1 Answer

Embarassingly enough, almost immediately after posting this, I found my answer. count_distinct() gets me what I needed.

filter @message like /ContactId/ | stats count_distinct(ContactId) as callCount by toMillis(datefloor(1d)) | sort callCount desc 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.