Java Web 应用程序健康检查良好实践
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14829495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java web application health check good practices
提问by levtatarov
I have a Java web app running (with Spring) and I wish to have a health check performed every few minutes. I'm not checking the Tomcat or the JVM but strictly on the application level so I have a few ideas for stuff to check.
我有一个 Java Web 应用程序正在运行(使用 Spring),我希望每隔几分钟执行一次运行状况检查。我不是在检查 Tomcat 或 JVM,而是严格检查应用程序级别,所以我有一些关于检查内容的想法。
For example:
例如:
- make a simple query to check DB sanity
- check that the environment is "production" (cause that's the only one that'll be monitored)
- 做一个简单的查询来检查数据库的完整性
- 检查环境是否为“生产”(因为这是唯一会被监控的环境)
Basically I'm looking for other ideas and suggestions for what to check or some best practices for it.
基本上,我正在寻找其他想法和建议,以了解要检查的内容或一些最佳实践。
Any ideas?
有任何想法吗?
采纳答案by yegor256
I'd recommend to try Metrics Framework
我建议尝试Metrics Framework
回答by Francois Lacoursiere
We have developed a special URL that accesses a spring mvc controller that tests various aspects of our application. You just need to return a 500 if your find anything wrong and give that url link to your favorite monitoring tool. We use both pingdom and nagios at our facility.
我们开发了一个特殊的 URL,它可以访问测试我们应用程序各个方面的 spring mvc 控制器。如果您发现任何错误,您只需要返回 500 并将该 url 链接提供给您最喜欢的监控工具。我们在我们的设施中同时使用 pingdom 和 nagios。
回答by ummm....
Perhaps create a page that is generated by the db, have some particular output on it that nagios checks for, so then you will know the http port is up, the webserver is actually serving a web page, and the db is able to be accessed by the app.
也许创建一个由 db 生成的页面,上面有一些 nagios 检查的特定输出,这样你就会知道 http 端口已启动,网络服务器实际上正在为一个网页提供服务,并且可以访问该 db通过应用程序。