You can get that info using get_log_events
e.g.
import boto3
logs_client = boto3.client('logs', region_name='us-east-2')
logGroupName='/aws/lambda/My_Function',
logStreamName='2022/07/09/[$LATEST]3aevb813776865536a146697b7379d5',
response = logs_client.get_log_events(
logGroupName=logGroupName,
logStreamName=logStreamName,
limit=123,
)
response
will have all the memory and duration info that you normally see in the console.
I hardcoded logGroupName and logStreamName but you can also just get them using describe_log_streams
Example below only gets the latest log stream.
stream_response = logs_client.describe_log_streams(
logGroupName = "/aws/lambda/My_Function",
orderBy='LastEventTime',
descending=True,
limit=1
)
print(stream_response)