Why did my CloudWatch canary stop running?

2 minute read
0

I created a canary in Amazon CloudWatch using AWS CloudFormation or the AWS Command Line Interface (AWS CLI). The canary automatically stopped running after a period of time. How can I troubleshoot this issue?

Resolution

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

If your CloudWatch canary stops running, check the "DurationInSeconds" value that you set when you created your canary. This value specifies the length of time (in seconds) that the canary continues to make regular runs according to the schedule in the "Expression" value. If you specify 0, then the canary continues making runs until you stop it. If you omit this field, then the default of 0 is used.

To check the value of your canary's "DurationInSeconds" parameter, run the Amazon CloudWatch Synthetics GetCanary API:

aws synthetics  get-canary --name [canary_name]

In the output, check the "DurationInSeconds" value:

{
    "Canary": {
        "Id": "a1495b85-1c60-4f29-92c1-540f62fa34e3",
        "Name": "canary_name",
        "Code": {
            "SourceLocationArn": "arn:aws:lambda:eu-west-1:YourAccount:layer:cwsyn-canary_name-a1495b85-1c60-4f29-92c1-540f62fa34e3:1",
            "Handler": "CanaryFunction.handler"
        },
        "ExecutionRoleArn": "arn:aws:iam::YourAccount:role/CanaryRoleName",
        "Schedule": {
            "Expression": "rate(2 minutes)",
            "DurationInSeconds": 360
        },
        "RunConfig": {
            "TimeoutInSeconds": 120
        },
        "SuccessRetentionPeriodInDays": 31,
        "FailureRetentionPeriodInDays": 31,
        "Status": {
            "State": "READY"
        },
        "Timeline": {
            "Created": 1594481063.96,
            "LastModified": 1594481063.96
        },
        "ArtifactS3Location": "S3_Bucket_for_artifacts",
        "EngineArn": "arn:aws:lambda:eu-west-1:YourAccount:function:cwsyn-canary_name-a1495b85-1c60-4f29-92c1-540f62fa34e3:1",
        "RuntimeVersion": "syn-1.0",
        "Tags": {}
    }
}

Note: In the response, "DurationInSeconds" is not equal to 0.

If the "DurationInSeconds" value doesn't match your intended duration, then run the CloudWatch Synthetics UpdateCanary API:

aws synthetics  update-canary --name canary_cli --schedule Expression="rate(2 minutes)",DurationInSeconds=0

Note: For the canary to continuously run, you must write the schedule expression with the "DurationInSeconds" set to 0.

To verify your changes, run the CloudWatch Synthetics get-canary command using the AWS CLI:

aws synthetics  get-canary --name [canary_name]


{
    "Canary": {
        "Id": "a1495b85-1c60-4f29-92c1-540f62fa34e3",
        "Name": "canary_name",
        "Code": {
            "SourceLocationArn": "arn:aws:lambda:eu-west-1:YourAccount:layer:cwsyn-canary_name-a1495b85-1c60-4f29-92c1-540f62fa34e3:1",
            "Handler": "CanaryFunction.handler"
        },
        "ExecutionRoleArn": "arn:aws:iam::YourAccount:role/CanaryRoleName",
        "Schedule": {
            "Expression": "rate(2 minutes)",
            "DurationInSeconds": 0
        },
        "RunConfig": {
            "TimeoutInSeconds": 120
        },
        "SuccessRetentionPeriodInDays": 31,
        "FailureRetentionPeriodInDays": 31,
        "Status": {
            "State": "READY"
        },
        "Timeline": {
            "Created": 1594481063.96,
            "LastModified": 1594481063.96
        },
        "ArtifactS3Location": "S3_Bucket_for_artifacts",
        "EngineArn": "arn:aws:lambda:eu-west-1:YourAccount:function:cwsyn-canary_name-a1495b85-1c60-4f29-92c1-540f62fa34e3:1",
        "RuntimeVersion": "syn-1.0",
        "Tags": {}
    }
}

In the output, confirm that the "DurationInSeconds" value is 0.


AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago