you can use filter.
fields @timestamp, @message
| filter @message like "65ddd20eac244AAe619383e4d8cb558834"
| sort @timestamp desc
| limit 20
it will filter all the messages limit to 20 that send by 65ddd20eac244AAe619383e4d8cb558834
.
update:
suppose the JSON log formate is this
{
"sender": "65ddd20eac244AAe619383e4d8cb558835",
"message": "Hi"
}
Now I want to count number of messages from 65ddd20eac244AAe619383e4d8cb558835
how many messages are coming from each user?
so simple you can run the query
stats count(sender) by sender |
# To filter only message the contain sender, to avoid lambda default logs
filter @message like "sender"
if you want to see messages as well then modify the query a bit
stats count(*) by sender, message |
filter @message like "sender"
Here @message
refers to whole to index where message
refer to the JSON object message
.

count_distinct
Returns the number of unique values for the field. If the field has
very high cardinality (contains many unique values), the value
returned by count_distinct
is just an approximation.
how many distinct users in the selected interval?
It will list distinct users in 3hr
of interval
stats count_distinct(sender) as distinct_sender by bin(3hr) as interval
