简体   繁体   English

如何为 Heroku 中的 memory 使用设置警报?

[英]How to setup alerts for memory usage in Heroku?

That, basically.基本上就是这样。 I have a Rails 5 application but really more on a general level Im trying to find a way to get email alerts when my dynos reach certain memory usage threshold.我有一个 Rails 5 应用程序,但实际上更多的是一般级别我试图找到一种方法来在我的测功机达到一定的 memory 使用阈值时获得 email 警报。 Im using one web and one worker.我使用一台 web 和一名工人。 Cant find anything.什么都找不到。

Heroku has an 'Application metrics' page which can also alert you on some conditions. Heroku 有一个“应用程序指标”页面,它还可以在某些情况下提醒您。 However there is no option for alerting for memory usage.但是,没有针对 memory 使用情况发出警报的选项。 We have asked Heroku support and this is their answer:我们询问了 Heroku 支持,这是他们的回答:

Yes, unfortunately there's not a built-in way to receive alerts about memory usage.是的,不幸的是,没有内置的方式来接收有关 memory 使用情况的警报。 However, you could potentially set up your Papertrail instance to alert you if your app emits an R14 or an R15.但是,您可能会设置 Papertrail 实例以在您的应用发出 R14 或 R15 时提醒您。 Keep in mind that those are cases where it might be too late to take any corrective action on memory as it is already alerting a disruption to the app.请记住,在这些情况下,对 memory 采取任何纠正措施可能为时已晚,因为它已经警告应用程序中断。

For more granularity, you'll need to enable the log-runtime-metrics lab so that your memory usage is printed to your application logs: https://devcenter.heroku.com/articles/log-runtime-metrics .要获得更详细的信息,您需要启用 log-runtime-metrics 实验室,以便将您的 memory 使用情况打印到您的应用程序日志中: https://devcenter.Z3115FB34DFCB5BA8AA049707C596B733

You can also use a log drain to parse, chart, and setup alerts for those errors.您还可以使用日志消耗来解析、绘制图表并为这些错误设置警报。 Librato is the most common tool I see customers using for that kind of workflow: https://elements.heroku.com/addons/librato . Librato 是我看到客户用于此类工作流程的最常用工具: https://elements.heroku.com/addons/librato

Relying on Papertrail is good enough for us for now, but we are still exploring other options.目前依靠 Papertrail 对我们来说已经足够了,但我们仍在探索其他选择。 One option is to simply use the Rails app to report its own memory usage, for example through a system call like this pmap #{Process.pid} | tail -1一种选择是简单地使用 Rails 应用程序报告它自己的 memory 使用情况,例如通过像这样的系统调用pmap #{Process.pid} | tail -1 pmap #{Process.pid} | tail -1 . pmap #{Process.pid} | tail -1 Another option is to use Monit ( https://mmonit.com/ ) but it's not very easy to set it up and configure.另一种选择是使用 Monit ( https://mmonit.com/ ),但设置和配置并不容易。 (You will need a custom build pack to run this on Heroku.) Also Heroku supports some 3rd party addons for monitoring which can send alerts, like New Relic. (您将需要一个自定义构建包才能在 Heroku 上运行它。)此外,Heroku 还支持一些 3rd 方插件进行监控,这些插件可以发送警报,例如 New Relic。

You can't in Heroku, but the best solution I've found so far is to use App Signal您不能在 Heroku 中,但到目前为止我发现的最佳解决方案是使用App Signal

They allow you to set up custom alerts for any metric they track, including host memory usage.它们允许您为它们跟踪的任何指标设置自定义警报,包括主机 memory 使用情况。

App Signal is a pretty solid APM in general too, so you can ditch New Relic, Scout, or whatever other tool you might be using as well. App Signal 通常也是一个非常可靠的 APM,因此您可以放弃 New Relic、Scout 或任何其他您可能正在使用的工具。

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

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