Skip to content

ConfigurationByExample

ryo-murai edited this page Feb 5, 2024 · 4 revisions

Example config files

See config-min-sample.json for minimal case or config-sample.json for more complex case.

Configuration Schema Specification

For complete configuration specification, refer Configuration.

Example Snippets

Configure Alarm

Monitoring Faults

  resources:
    lambda:
      target_resource_type: "lambda:function"
      alarm:
        metrics:
        - Errors

This has the effect of raising an alarm if Errors occurs in the lambda function. By default, the following properties are set for alarms. By this config, if the Errors metric is reported once in 60 seconds, an alarm is triggered.

Property Value
Statistic "Sum"
Period 60
EvaluationPeriods 1
Threshold 1
ComparisonOperator "GreaterThanOrEqualToThreshold"

This default value is intended to detect the occurrence of faults such as Errors and Throttled.

Configure Alarm Properties

  • alarm_param_overrides: give metric name as a key, and alarm properties as a value.
  resources:
    sqs:
      target_resource_type: "sqs:queue"
      alarm:
        metrics:
        - ApproximateAgeOfOldestMessage
        alarm_param_overrides:
          ApproximateAgeOfOldestMessage:
            Statistic: Maximum
            Threshold: 3600
            ComparisonOperator: GreaterThanThreshold

This has the effect of raising an alarm if a message exists in the SQS queue for more than 3,600 seconds.

Alarm Notification

  • globals > alarm > alarm_actions: give a list of ARNs of alarm action. Typically, SNS Topic ARN to notify the alarm. For supported actions in CloudWatch, refer document.
  globals:
    alarm:
      alarm_actions:
      - arn:aws:sns:region:account-id:sns-topic-name
  resources:
    # omit ...

Note: The alarm actions may be given also by CLI option, then those lists are concatenated at creating of the alarm.

alarm-craft -n "arn:aws:sns:region:account-id:sns-topic"

Filter monitoring target resources

Filter by resource name

  resources:
    lambda:
      target_resource_name_pattern: "^abc-(prod|stage|dev)-"
      # ... (omit)

This has the effect of limiting the monitoring to those resource names beginning with "abc-prod-", "abc-stage-" or "abc-dev-".

Filter by tag(s)

  • target_resource_tags: giving two or more tags requires having ALL specified tags.
  resources:
    lambda:
      target_resource_tags:
        Owner: mydivision
        Environment: production
      # ... (omit)

This has the effect of limiting the monitoring to those resources tagged with "Owner": "mydivision" and "Environment": "production".

Specify Filter globally

  • globals > resource_filter: may specify target_resource_name_pattern and target_resource_tags. It takes effect to all resource configs under resources section.
  globals:
    resource_filter:
      target_resource_tags:
        Owner: mydivision
  resources:
    lambda:
      target_resource_type: lambda:function
      # ... (omit)
    sfn:
      target_resource_type: states:stateMachine
      # ... (omit)

This has the effect of limiting the monitoring to lambda:function and states:stateMachine resources tagged with "Owner": "mydivision".
This section is intended to be configured based on your resource naming rules and tagging strategies.