I would like to configure an AWS::Logs::MetricFilter, so that I can get a counter of logs which match a particular pattern.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-metricfilter.html
However, this particular CloudFormation resource is not listed in the Serverless CF resource reference at
Does this mean that Serverless would need to be updated to support this? Or can I put unlisted CF resources in the YAML?
Thanks,
Brian.
buggy
2
I’m not familiar with this particular resource but in general you can use unlisted resources.
rowanu
3
Yep, it’s just CloudFormation, so put in the resources
section.
If you’re looking to filter your Lambda functions’ logs, you’ll need to work out their resource names from the docs.
Thanks @buggy and @rowanu. For reference, this works:
resources:
Resources:
ApiMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
FilterPattern: SYS-EXCEPTION
LogGroupName:
Ref: ApiLogGroup
MetricTransformations:
- MetricName: sys-exception-api-${self:custom.stage}
MetricNamespace: LogMetrics
MetricValue: "1"
(Sadly, CloudFormation doesn’t allow setting DefaultValue: 0.0
under MetricTransformations, but that’s not Serverless’ fault)
Cheers,
Brian.
1 Like