I need to create a metric filter for API Gateway Log Group which is created by serverless restApi true option. I don’t know how to set DependOn option with API Gateway Log group and set a custom log group name. I tried to make the metric filter depending on ApiGatewayRestApi but I get the specified log group does not exist error. I think that at the time the metric filter is created, the log group still does not exist. I should make the metric filter depend on API Gateway Log group but I don’t know its Logical ID.
This is my metric filter:
ApiMetricFilter:
DependsOn: ApiGatewayRestApi
Type: "AWS::Logs::MetricFilter"
Properties:
LogGroupName:
Fn::Join:
- ""
- - "API-Gateway-Execution-Logs_"
- Ref: "ApiGatewayRestApi"
- "/"
- ${self:custom.stage}
FilterPattern: '{ ($.status = "5**") && ($.status != "503") }'
MetricTransformations:
-
MetricName: 5XX-${self:custom.cloudwatchAlarmName}-${self:custom.stage}
MetricNamespace: LogMetrics
MetricValue: 1