by

Easy API Gateway/Lambda “Serverless” API Logging/Debugging

Developing and testing “serverless” APIs using Amazon API Gateway and AWS Lambda can be made much easier with built-in support for CloudWatch Logs.

In Lambda functions you can use log statements to send log events to CloudWatch Log streams, and API Gateway automatically submits log events for requests to APIs with logging enabled.

However, it can be difficult to reconcile log events for a serverless API sent across multiple CloudWatch log groups and log streams. Tracking down logs for a specific request or tailing request logs for a serverless API can be a cumbersome experience.

To help improve the serverless dev/debug/test experience, I’ve released a fork of the excellent awslogs project to include native support for API Gateway/Lambda serverless APIs. Given an API Gateway REST API ID and Stage name, this tool produces an aggregated stream of time-ordered*, color-coded log events emitted by API Gateway and all Lambda functions attached to your API. The log events can then be further filtered and processed by standard command-line tools.

i.e. stream all log events emitted from API Gateway as well as from all Lambda functions attached to the API:

apilogs get --api-id xyz123 --stage prod --watch

or search APIG/Lambda logs for events from a specific request ID in the past hour:

apilogs get --api-id xyz123 --stage prod --start='1h ago' | grep "6605b081-6f04-11e6-97ac-c34deb0b3dd9"

Tip: To correlate API Gateway request IDs with Lambda invocations, send $context.requestId to your Lambda function via a mapping template and include it in your Lambda log messages (i.e. console.log(event.apiRequestId + ” – log message”);)

Check out ‘apilogs’ here. Fixes and contributions are greatly appreciated.

Happy debugging!
Ryan

Write a Comment

Comment

Webmentions

  • chubby gay mens dating sites

    gay dating a macho https://speedgaydate.com/

  • dos chicos se conocieron en un chat gay

    gay men chat cam https://gay-buddies.com/

  • chat gay free

    chat with gay men https://gaytgpost.com/

  • gay men vs women dating as a bi man

    triad gay dating sites https://gaypridee.com/

  • free asian chat lines gay

    free gay bi chat lines in seattle wa https://bjsgaychatroom.info/

  • best gay dating sites for southwest florida

    gay men dating sites missouri https://gaysugardaddydatingsites.com

  • gay teen dating

    gay black dating apps for fat black gay men https://gayfade.com

  • gay bear dating

    gay trucker dating https://speedgaydate.com

  • dating a bipilar gay guy

    steve cardenas dating gay https://gayprideusa.com

  • older gay dating app

    gay mature daddy dating site https://gay-buddies.com

  • gay christian dating

    dating guys when 18 gay https://gaypridee.com

  • 3password

    2documentation

  • funny games biz sex

    truth or dare sex games 69 https://sexgameszone.com/

  • shota boys sex games

    free 3d adult sex games https://cybersexgames.net/

  • write an expository essay

    write a persuasive essay https://dollaressays.com/

  • paid essay writing

    writing a descriptive essay https://essaytodo.com/

  • real online casino

    free no deposit casino https://casinoonlinek.com/

  • reflective essay on writing

    essay writing online https://onlinecasinos4me.com/

  • write my college essay

    help writing essays https://essaytag.com/

  • writing a personal essay

    what to write an essay on https://essaypoints.com/

  • pay to write essay

    writing persuasive essay https://essaywritercentral.com/

  • argument essay writing

    writing an essay intro https://essayghostwriter.com/

  • over 40 gay dating site

    free gay dating in duluth mn https://dating-gaym.com/

  • romeo gay dating

    gay dating website free https://gayedating.com/

  • best gay dating sites canada

    anchorage gay dating https://gay-singles-dating.com/

  • surge gay dating reddit

    gay dating games https://gayonlinedating.net/

  • gay dating sim site for android

    gay dating chicago https://datinggayservices.com/

  • gay dating sites in india

    gay dating site https://gaydatinglosangeles.com/

  • dating for gay daddies

    sa gay dating site https://gaychatgay.com/

  • gay bear dating sites

    maleforce gay chat

  • keto diet dangerous

    keto friendly foods https://ketodietione.com/