Skip to content

Commit ebf98ef

Browse files
docs: update README.md
1 parent 92df29d commit ebf98ef

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,71 @@ alarms:
332332
treatMissingData: ignore # default
333333
```
334334

335+
#### Custom CloudWatch Alarm names
336+
337+
By default, the CloudFormation assigns names to the alarms based on the CloudFormation stack and the resource logical Id, and in some cases and these names could be confusing.
338+
339+
To use custom names to the alarms add `nameTemplate` property in the `alarms` object.
340+
341+
example:
342+
343+
```yaml
344+
service: myservice
345+
346+
plugins:
347+
- serverless-step-functions
348+
349+
stepFunctions:
350+
stateMachines:
351+
main-workflow:
352+
name: main
353+
alarms:
354+
nameTemplate: $[stateMachineName]-$[cloudWatchMetricName]-alarm
355+
topics:
356+
alarm: !Ref AwsAlertsGenericAlarmTopicAlarm
357+
metrics:
358+
- executionsFailed
359+
- executionsAborted
360+
- executionsTimedOut
361+
- executionThrottled
362+
treatMissingData: ignore
363+
definition: ${file(./step-functions/main.asl.yaml)}
364+
```
365+
366+
Supported variables to the `nameTemplate` property:
367+
368+
- `stateMachineName`
369+
- `metricName`
370+
- `cloudWatchMetricName`
371+
372+
##### Per-Metric Alarm Name
373+
374+
To overwrite the alarm name for a specific metric, add the `alarmName` property in the metric object.
375+
376+
```yaml
377+
service: myservice
378+
379+
plugins:
380+
- serverless-step-functions
381+
382+
stepFunctions:
383+
stateMachines:
384+
main-workflow:
385+
name: main
386+
alarms:
387+
nameTemplate: $[stateMachineName]-$[cloudWatchMetricName]-alarm
388+
topics:
389+
alarm: !Ref AwsAlertsGenericAlarmTopicAlarm
390+
metrics:
391+
- metric: executionsFailed
392+
alarmName: mycustom-name-${self:stage.region}-Failed-alarm
393+
- executionsAborted
394+
- executionsTimedOut
395+
- executionThrottled
396+
treatMissingData: ignore
397+
definition: ${file(./step-functions/main.asl.yaml)}
398+
```
399+
335400
### CloudWatch Notifications
336401

337402
You can monitor the execution state of your state machines [via CloudWatch Events](https://aws.amazon.com/about-aws/whats-new/2019/05/aws-step-functions-adds-support-for-workflow-execution-events/). It allows you to be alerted when the status of your state machine changes to `ABORTED`, `FAILED`, `RUNNING`, `SUCCEEDED` or `TIMED_OUT`.

0 commit comments

Comments
 (0)