1

I do not want to wait for 14 seconds to read CloudWatch Lambda logs. Is there any way to read them in realtime in invoking shell on premises (outside VPC)?

  1. Invoke async
    result = lam.invoke(
        InvocationType='Event',
        FunctionName='my-lambda-func',
        Payload=json.dumps(dict(test='test'))
    )
  1. Lambda writes logs to a service in question.
  2. Loop/wait for real-time results in the same on separate shell.
3
  • Why not simply return the data rather than trying to extract it from logs? Commented Aug 23, 2021 at 23:26
  • 1
    @JohnRotenstein Async invocation does not return output from lambda in that case. Commented Aug 24, 2021 at 0:21
  • Then call it synchronously instead of asynchronously and simply return the data. Why does the OP want to read the data from logs? Commented Aug 24, 2021 at 1:43

1 Answer 1

1

A common way to use async invocation is to have your lambda publish your results to SQS queue or SNS topic. This way you can pull SQS queue on premise for results, or setup http endpoint subscription which will be automatically invoked by SNS when it gets a message from the lambda.

If you only want to focus on CloudWatch logs, then you can setup subscription filter on the logs for real-time processing of the incoming log events from lambda. Depending on your exact setup, you can use Kinesis, firehose or other lambda to get the log messages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.