How can I set the log_stream_prefix to get the cloudwatch data from lambda

21 views Asked by At

I am trying to get the log from the cloudwatch

my source code is like this below

I can find the group_name in cloudwatch console /aws/lambda/mylambda

logGroupName = "/aws/lambda/mylambda"

response = logs.describe_log_streams(
        logGroupName=group_name,
        logStreamNamePrefix=log_stream_name_prefix,
        orderBy='LogStreamName',
        descending=True,
    )

however, example my log_stream_name is changed like this below.

2023/05/01/[$LATEST]e6a2f85f7eb74aa9bde07837fc971df7
2023/04/30/[$LATEST]39b7ffa511434a65ba4bb4bd915485fd
2023/04/29/[$LATEST]3c2c75965ef2422f86b1624ef042d54b

What should I set for log_stream_name_prefix?

1

There are 1 answers

0
Mark B On BEST ANSWER

It is asking for the prefix (the first part of the name) not the full name. So for example to query all log streams for the day of 2023/04/29 the log stream prefix would be: 2023/04/29/[$LATEST]