简体   繁体   English

基于 Ec2 中文件存在的 CloudWatch 警报

[英]CloudWatch Alarms based on file existence in Ec2

I have a requirement to monitor for a specific file in the /mnt/file-i-need-to-monitor.txt path where I need to;我需要在我需要的/mnt/file-i-need-to-monitor.txt路径中监视特定文件;

  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.我查看了aws log agent ,但它似乎用于将任何自定义日志推送到日志组。

Can someone help me fix this?有人可以帮我解决这个问题吗?

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对于您的情况,您可以使用 aws cli 推送自定义指标,如果此自定义指标大于 1,则基于控制台创建警报

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM