http健康检查规范?

Spec for http health checks?

我想实现一个简单的健康检查并通过 http 提供。

到目前为止,我只有编写nagios 插件的经验。 Nagios 有这个 API spec

是否已经有一种通用的方法来编写供应商中立的健康检查?

如果不是,应该进行什么健全的健康检查 return 以使其可移植到许多不同的监控服务器实现中?

虽然健康检查的格式没有标准,但您应该考虑主要的监控工具及其对您的协议的期望。 在大多数情况下,它们会对特定的 HTTP 应答代码做出反应。 例如 Amazon Route 53:

waits for an HTTP status code of 200 or greater and less than 400

另一个工具,Consul,有more specific definition

The status of the service depends on the HTTP response code: any 2xx code is considered passing, a 429 Too Many Requests is a warning, and anything else is a failure.

因此,您可能需要检查一些您稍后可能会集成的顶级工具,并选择适合所有这些工具的方法。