0
votes

Reading the documentation seems that is possible in AWS Cloudwatch to run queries with multiple log groups but I can not see any example on how to do it.

I would like to join two log groups using common attributes and select some logs using filter.

Has anyone run into the same problem and found a solution? Thanks in advance.

1
You can refer CloudWatch Logs Insights Query Syntax. Some of the examples are examples1, examples2 , example3 - amitd
thanks for your prompt response but in these examples I can't see how to 'join' different log groups - JourneyToJsDude

1 Answers

0
votes

If you are talking about AWS Console, the option to select multiple log groups is a checkbox and you can select over 20 log groups. AWS CloudWatch Insights Console

If you refer to the AWS CLI, you can also choose multiple log groups. First create the query (in one or more log groups) (https://docs.aws.amazon.com/cli/latest/reference/logs/start-query.html) and then get the results (https://docs.aws.amazon.com/cli/latest/reference/logs/get-query-results.html)

Example:

Query creation with multiple log groups:

aws logs start-query --log-group-names "/aws/apigateway/welcome" "/aws/lambda/Test01" 
--start-time 1598936400000 --end-time 1611464400000 --query-string "fields @timestamp, 
@message"

Recover result from created query:

aws logs get-query-results --query-id <query_id>

AWS CLI CloudWatch Insights