Name: serverless-plugin-aws-alerts
Owner: AutoScout24
Owner: AutoScout24
Description: A Serverless Framework plugin that creates CloudWatch alarms for functions.
Forked from: ACloudGuru/serverless-plugin-aws-alerts
Created: 2017-03-28 14:56:29.0
Updated: 2017-03-28 14:56:31.0
Pushed: 2017-10-11 18:41:11.0
Size: 92
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Serverless plugin to easily add CloudWatch alarms to functions
npm i serverless-plugin-aws-alerts
ice: your-service
ider:
me: aws
ntime: nodejs4.3
om:
erts:
stages: # Optionally - select which stages to deploy alarms to
- producton
- staging
topics:
ok: ${self:service}-${opt:stage}-alerts-ok
alarm: ${self:service}-${opt:stage}-alerts-alarm
insufficientData: ${self:service}-${opt:stage}-alerts-insufficientData
definitions: # these defaults are merged with your definitions
functionErrors:
period: 300 # override period
customAlarm:
namespace: 'AWS/Lambda'
metric: duration
threshold: 200
statistic: Average
period: 300
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
global:
- functionThrottles
- functionErrors
function:
- functionInvocations
- functionDuration
table:
- dynamoDbReadThrottleEvents
- dynamoDbWriteThrottleEvents
ins:
serverless-plugin-aws-alerts
tions:
o:
handler: foo.handler
alarms: # merged with function alarms
- customAlarm
- name: fooAlarm
namespace: 'AWS/Lambda'
metric: errors # define custom metrics here
threshold: 1
statistic: Minimum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
Some metrics are not related to single Lambda functions, but for the whole service e.g. API Gateway 5XX errors or DynamoDB metrics. If you want to create alrams for those metrics, just put them in the global
area.
Alarms defined here will be applied for all dynamoDb tables defined in the resources section of the serverless project.
If topic name is specified, plugin assumes that topic does not exist and will create it. To use existing topics, specify ARNs instead.
You can monitor a log group for a function for a specific pattern. Do this by adding the pattern key. You can learn about custom patterns at: http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html
The following would create a custom metric log filter based alarm named barAlarm
. Any function that included this alarm would have its logs scanned for the pattern exception Bar
and if found would trigger an alarm.
om:
erts:
function:
- name: barAlarm
metric: barExceptions
threshold: 0
statistic: Minimum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
pattern: 'exception Bar'
- name: bunyanErrors
metric: BunyanErrors
threshold: 0
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
pattern: '{$.level > 40}'
Note: For custom log metrics, namespace property will automatically be set to stack name (e.g.
fooservice-dev
).
The plugin provides some default definitions that you can simply drop into your application. For example:
ts:
obal:
- functionThrottles
- functionErrors
nction:
- functionInvocations
- functionDuration
If these definitions do not quite suit i.e. the threshold is too high, you can override a setting without creating a completely new definition.
ts:
finitions: # these defaults are merged with your definitions
functionErrors:
period: 300 # override period
The default definitions are below.
nitions:
nctionInvocations:
namespace: 'AWS/Lambda'
metric: Invocations
threshold: 100
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
nctionErrors:
namespace: 'AWS/Lambda'
metric: Errors
threshold: 10
statistic: Maximum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
nctionDuration:
namespace: 'AWS/Lambda'
metric: Duration
threshold: 500
statistic: Maximum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
nctionThrottles:
namespace: 'AWS/Lambda'
metric: Throttles
threshold: 50
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
iGateway5xx:
namespace: 'AWS/ApiGateway'
metric: 5XXError
threshold: 1
statistic: Sum
period: 60,
evaluationPeriods: 1,
comparisonOperator: 'GreaterThanThreshold'
iGateway4xx:
namespace: 'AWS/ApiGateway'
metric: 4XXError
threshold: 10
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
namoDbReadThrottleEvents:
namespace: 'AWS/DynamoDB'
metric: ReadThrottleEvents
threshold: 5,
statistic: Sum
period: 300,
evaluationPeriods: 1,
comparisonOperator: GreaterThanThreshold
namoDbWriteThrottleEvents:
namespace: 'AWS/DynamoDB'
metric: WriteThrottleEvents
threshold: 5
statistic: Sum
period: 300
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
MIT © A Cloud Guru