CloudWatch Alarm to Monitor Daily Job

0

We have a legacy cron job which is expected to run on a daily basis, the only metric the job is publishing is Time metric.

Ask

We want to monitor 1 thing for this job:

  1. It indeed runs on a daily basis, if dp is missing in a day, then alarm

Problem

For this cron job, I created a alarm as:

Period: 1 day
Evaluation Period: 1 day
Datapoint to alarm: 1
TreatMissingData: BREACH

However I would get this validation error from CW:

Metrics cannot be checked across more than a day (EvaluationPeriods * Period must be <= 86400) 

Question

If I set period to, say, 5min, then I have to set TreatMissingData: NOT_BREACH? as within 5min, there won't be a dp published by the job unless the job actually ran at the scheduled hour.

How should I set the correct alarm here? any suggestions?

Dawn
asked 21 days ago135 views
1 Answer
0

Hello.

As you know, the evaluation period for CloudWatch alarms cannot exceed one day.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html

The maximum value, calculated by multiplying the alarm period by the number of evaluation periods used, is one day (86,400 seconds). This quota cannot be changed.

If you set it to "notBreaching", it may depend on how the metrics are registered, but even if no data is sent when cron execution fails, it may be determined to be normal.
If data is not sent to metrics when cron fails, I think it is necessary to set it to "breaching".
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-and-missing-data

notBreaching – Missing data points are treated as "good" and within the threshold

How about setting the cron execution interval to every hour or so so that it does not perform any processing other than sending data to CloudWatch outside of a specific time?
For example, let's imagine creating a shell script like the one below.
The shell script below performs processing when executed at 10 am, and only sends data to CloudWatch metrics at other times.

#!/bin/bash

# now time
current_hour=$(date +%H)

if [ "$current_hour" -eq 10 ]; then
  # example command
  echo "example command"
  aws cloudwatch put-metric-data --metric-name "metric_name" --namespace "namespace_name" --value 1
else
  # If executed at a time other than 10:00
  aws cloudwatch put-metric-data --metric-name "metric_name" --namespace "namespace_name" --value 1
fi
profile picture
EXPERT
answered 21 days ago
profile pictureAWS
EXPERT
reviewed 21 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions