Code Monkey home page Code Monkey logo

serverless-restapi-log's Introduction

serverless-restapi-log

This Serverless-restapi-log plugin enables you to have apigateway log group maintained through serverless cloudformation template. If this plugin is enabled, it enable restapi logs as well on apigateway

In any case this plugin is removed, log group will be removed as it no longer be part of the stack template. Howevver, restapi is still enabled but no log being captured. To disbale this, a custom pre deploy script is needed to check this plugin is enabled, otherwise disable the log

Installation

First, add `serverless-restapi-log to your project:

npm install serverless-restapi-log

Then inside your project's serverless.yml file, add following entry to the plugins section

plugins:
  - serverless-restapi-log

See example

Configuration

Plugin need to be configured with a log group, and a format. Log group just need a name, plugins takes care to ensure CloudWatchLogGroup creation.

To configure it, add something like the following to your serverless.yml.

custom:
  serverless-restapi-log:
    log-group: /aws/my-api/${self:provider.stage}/access-logs
    format: '{ "requestId":"$context.requestId", "ip": "$context.identity.sourceIp", "caller":"$context.identity.caller", "user":"$context.identity.user","requestTime":"$context.requestTime", "httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath", "status":"$context.status","protocol":"$context.protocol", "responseLength":"$context.responseLength" }'
    log-group-retention: 14 # optional, default to 7

serverless-restapi-log's People

Contributors

lifengkow avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.