1

I have a requirement to monitor for a specific file in the /mnt/file-i-need-to-monitor.txt path where I need to;

  1. Create alarms if the file doesn't exist anymore.
if [ ! -f /mnt/file-i-need-to-monitor.txt ]; then
    // create aws alarm and notify via an email
fi

How can I integrate this methodology?

I have looked into the aws log agent but it seems like it is for pushing any custom logs to a log group.

Can someone help me fix this?

Jananath Banuka
  • 2,951
  • 8
  • 57
  • 105

1 Answers1

2

Hello Jananath Banuka,

For your case, you can use aws cli to push a custom metric, And you create an alert based on the console if this custom metric if you have > 1

https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/put-metric-data.html

Hatim
  • 1,116
  • 1
  • 8
  • 14
  • I got it, thanks. So, to clarify few things,`1. push a custom metric`, `2.create an alarm`. Is that it? – Jananath Banuka Jan 11 '22 at 14:18
  • Yes @JananathBanuka, push the custom metric with the value 1 numeric, you perform the count in the alarm part if you receive value > 0 in 5 min you trigger the alarm – Hatim Jan 11 '22 at 14:27
  • Two values should be either `1` or `0` right? `1` means file exist and `0` means file doesn't exist? – Jananath Banuka Jan 11 '22 at 14:29
  • The best is use count value, once you get the file put data as value 1 like : "Value": 1 , and in your alert dashboard you test if count > 0 – Hatim Jan 11 '22 at 14:31