[英]Getting AWS Elastic Beanstalk health code programatically via php
I have an AWS Elastic Beanstalk instance on which I have some crons running. 我有一个AWS Elastic Beanstalk实例,我在其上运行了一些crons。 I occasionally have issues
我偶尔会有问题
Environment health has transitioned from Ok to Severe. 4.5 % of the requests to the ELB are failing with HTTP 5xx (2 minutes ago)
I have alarms set to let me know about this, and that part is working correctly. 我有警报设置让我知道这一点,那部分工作正常。 But I want to stop the crons from executing if the environment health status is not "OK" or "Warning".
但是如果环境健康状态不是“OK”或“Warning”,我想阻止crons执行。 Is there a way to programatically get the health status code (shown in image below, circled in red) from a php script running on the same instance?
有没有办法以编程方式从同一实例上运行的php脚本获取健康状态代码(如下图所示,红色圈出)?
I would use CloudWatch alarm to trigger sending a notification email in such event. 在这种情况下,我会使用CloudWatch警报触发发送通知电子邮件。
The first thing to understand is that Elastic Beanstalk to a convenient tool to bootstrap the infrastructure on AWS. 首先要了解的是Elastic Beanstalk是一个方便的工具,用于在AWS上引导基础架构。 Anything you setup with Elastic Beanstalk, either via its cli or console, you can pretty much do the same on the EC2 page.
使用Elastic Beanstalk设置的任何东西,无论是通过它的cli还是控制台,你都可以在EC2页面上做同样的事情。
Assuming you have a health
script within your application that beanstalk pings periodically, you should be able to determine if your app is healthy or not within your application. 假设您的应用程序中有一个
health
脚本定期查找bean,您应该能够确定您的应用程序在您的应用程序中是否健康。 You should not rely on having to programically get the status from Benstalk. 您不应该依赖于以编程方式从Benstalk获取状态。
For example, within your health
script you can set a flag if your application is healthy or not. 例如,如果您的应用程序运行正常,您可以在
health
脚本中设置标志。 Such flag can be in the form of a touched file in the filesystem. 这种标志可以是文件系统中被触摸的文件的形式。 Or a flag somewhere in a cache if you use one.
或者如果您使用缓存,则在缓存中的某个位置标记。 Ex: Memcache.
例如:Memcache。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.