简体   繁体   English

时间相关的 cloudwatch 监控是否可行?

[英]Time dependent cloudwatch monitoring is possible?

I want to monitor my EC2 instance state (running or stop) and set alarm in case, EC2 stop.我想监控我的 EC2 实例 state(运行或停止)并设置警报以防 EC2 停止。 My EC2 will run only from 9AM to 6PM.我的 EC2 只在上午 9 点到下午 6 点运行。 Can i accomplish above through cloudwatch and how?我可以通过 cloudwatch 完成上述任务吗?如何完成?

You could use CloudWatch Event Schedule Expressions rule:您可以使用 CloudWatch 事件计划表达式规则:

You can create rules that self-trigger on an automated schedule in CloudWatch Events using cron or rate expressions.您可以使用 cron 或 rate 表达式在 CloudWatch Events 中创建自动触发的规则。 All scheduled events use UTC time zone and the minimum precision for schedules is 1 minute.所有计划的事件都使用 UTC 时区,并且计划的最小精度为 1 分钟。

For example.例如。

One rule would start the instance at 9 AM from MON-FRY一条规则将在上午 9 点从 MON-FRY 开始实例

0 9 ? * MON,TUE,WED,THU,FRI *

在此处输入图像描述

Other rule would stop the instance其他规则将停止实例

0 18 ? * MON,TUE,WED,THU,FRI *

在此处输入图像描述

For starting the instance you would need to create a lambda function .要启动实例,您需要创建一个lambda function For stopping you call StopInstance API directly using CloudWatch trigger:要停止,您可以直接使用 CloudWatch 触发器调用 StopInstance API:

在此处输入图像描述

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

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