# serverless-logs-plugin

> A serverless framework plugin for AWS to add log retention and the resource to subscribe log groups

Latest version **0.0.7** (published 2018-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install serverless-logs-plugin
pnpm add serverless-logs-plugin
yarn add serverless-logs-plugin
bun add serverless-logs-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2018-06-27 |
| First published | 2018-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alessio Santacroce |
| Maintainers | alessio.santacroce |
| Keywords | serverless, aws, plugin, log, SubscriptionFilter |

## Links

- npm: https://www.npmjs.com/package/serverless-logs-plugin
- Repository: https://github.com/alessio-santacroce/serverless-logs-plugin
- Homepage: https://github.com/alessio-santacroce/serverless-logs-plugin#readme
- Issues: https://github.com/alessio-santacroce/serverless-logs-plugin/issues
- npm.io page: https://npm.io/package/serverless-logs-plugin

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.7 (latest) — 2018-06-27
- 0.0.6 — 2018-06-27
- 0.0.5 — 2018-06-27
- 0.0.4 — 2018-06-26
- 0.0.3 — 2018-06-26
- 0.0.2 — 2018-06-26
- 0.0.1 — 2018-06-26

## README

# serverless-logs-plugin
A serverless framework plugin for AWS to add log retention and the resource to subscribe log groups


## Usage

Install from npm:
```
npm i --save serverless-logs-plugin
```

In serverless.yml add the plugin:
```
plugins:
  - serverless-logs-plugin
```

In serverless.yml add the configuration:
```
...
provider:
  logsPlugin:
    LogGroup:
      RetentionInDays: 14  # optional, default: 90
    SubscriptionFilter: # optional, default: no SubscriptionFilter resource is added
      DestinationArn: my-destination-arn
      FilterPattern: my-filtern-pattern  # optional, default: '{ $.NotExistingField NOT EXISTS }'
      RoleArn: my-role-arn  # optional, default: null
    additionalSubscriptions: # optional, default: no additional SubscriptionFilter
      - DependsOn: ElasticBeanstalkApp
        LogGroupNames:
          - /aws/elasticbeanstalk/myapp/var/log/eb-activity.log
          - /aws/elasticbeanstalk/myapp/var/log/nginx/access.log
          - /aws/elasticbeanstalk/myapp/var/log/nginx/error.log
          - /aws/elasticbeanstalk/myapp/var/log/web-1.error.log
          - /aws/elasticbeanstalk/myapp/var/log/web-1.log
...
```

As a result, the plugin will produce, for each lambda function a resource to set the RetentionInDays to the log group and a resource to subscribe the log group:
```
    "MyFunctionLogGroup": {
      "Type": "AWS::Logs::LogGroup",
      "Properties": {
        "LogGroupName": "/aws/lambda/MyFunction",
        "RetentionInDays": 90
      }
    },
    "MyFunctionSubscriptionFilter": {
      "Type": "AWS::Logs::SubscriptionFilter",
      "DependsOn": "MyFunctionLambdaFunction",
      "Properties": {
        "DestinationArn": "my-destination-arn",
        "LogGroupName": "/aws/lambda/MyFunction",
        "FilterPattern": "{ $.NotExistingField NOT EXISTS }"
      }
    }  
```

For each additionalSubscriptions, a subscription resource is produced:
```
    "AwselasticbeanstalkmyappvarlogwebDash1logSubscriptionFilter": {
      "Type": "AWS::Logs::SubscriptionFilter",
      "DependsOn": "ElasticBeanstalkApp",
      "Properties": {
        "DestinationArn": "my-destination-arn",
        "LogGroupName": "/aws/elasticbeanstalk/myapp/var/log/web-1.log",
        "FilterPattern": "{ $.NotExistingField NOT EXISTS }"
      }
    }
```

---
_Source: https://npm.io/package/serverless-logs-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
