AWS CloudWatch Log Insights Get Count of Unique Logs - gecko-8/devwiki GitHub Wiki
You can use the "| dedup " filter.
For example, to get the unique message_ids in a list of logs with NullReferenceException in the @message field:
fields message_id, @message
| filter @message LIKE /NullReferenceException/
| sort @timestamp asc
| dedup message_id