Skip to content

Commit defb430

Browse files
committed
feat: add custom metrics
1 parent 5fe2dd6 commit defb430

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

template.yaml.tpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ Resources:
223223
EntryPoints:
224224
- src/index.ts
225225

226+
## Metric filters
227+
228+
ReceivedMetricFilter:
229+
Type: AWS::Logs::MetricFilter
230+
Properties:
231+
LogGroupName: !Sub "/aws/lambda/${EventStreamProcessing}"
232+
FilterPattern: '{ $.received = * }' # Matches JSON status logs
233+
MetricTransformations:
234+
- MetricNamespace: !Sub "${EventStreamProcessing}"
235+
MetricName: "ReceivedCount"
236+
MetricValue: "$.received" # Extracts the "received" field as the metric value
237+
238+
FailedMetricFilter:
239+
Type: AWS::Logs::MetricFilter
240+
Properties:
241+
LogGroupName: !Sub "/aws/lambda/${EventStreamProcessing}"
242+
FilterPattern: '{ $.received = * }' # Matches JSON status logs
243+
MetricTransformations:
244+
- MetricNamespace: !Sub "${EventStreamProcessing}"
245+
MetricName: "FailedCount"
246+
MetricValue: "$.failed" # Extracts the "failed" field as the metric value
247+
226248
## S3 Buckets
227249
DlqBucket:
228250
Type: AWS::S3::Bucket

0 commit comments

Comments
 (0)