简体   繁体   English

监控 AWS 中的数据库趋势

[英]Monitoring DB trends in AWS

I was wondering about what the best workflows/tools are for the following scenario.我想知道以下场景的最佳工作流程/工具是什么。

Imagine you receive data from N restaurants, on a daily basis, like how many drinks, dishes of certain type, total order count etc etc, a restaurant made.想象一下,您每天从N家餐厅接收数据,例如一家餐厅制作了多少饮料、某种类型的菜肴、总订单数等。 All these entries go into a postgres DB, described best by the following fields {ID, datetime, restaurant, type_record, count} .所有这些条目都进入 postgres 数据库,最好由以下字段{ID, datetime, restaurant, type_record, count} Number of restaurants is in the 100's, so I need something that does not need to be updated with a CONFIG file every time a restaurant is added to the system.餐馆的数量在 100 家左右,所以我需要一些不需要在每次将餐馆添加到系统时都用CONFIG文件更新的东西。

Now I want to run a daily script that:现在我想运行一个daily脚本:

  1. Runs basic queries against the DB.对数据库运行基本查询。

  2. Makes some basic calculations.进行一些基本的计算。

  3. Catches something like number of drinks for today for restaurant X is 15% higher than its daily average`.例如number of drinks for today for restaurant X比其每日平均水平高 15%。

  4. If step 3 is beyond a certain threshold, push an alert to slack or pagerduty.如果第 3 步超出某个阈值,则向 slack 或 pagerduty 推送警报。

The question is: with which aws service should I perform step 3?问题是:我应该使用哪个 aws 服务执行第 3 步?

All I can think of is to run this code on a simple lambda function .我能想到的就是在一个简单的lambda function上运行这段代码。 This implementation would mostly suffice but I was wondering if there are smarter/better ways to achieve this.这个实现基本上就足够了,但我想知道是否有更聪明/更好的方法来实现这一点。

Details:细节:

Latency of the query (steps 1 and 2) are not a problem, nor step 4. The main problem is how to have such a trend monitoring system on the DB that is as simple as possible (easy to maintain).查询的延迟(第1步和第2步)不是问题,第4步也不是问题。主要问题是如何在DB上拥有这样一个尽可能简单(易于维护)的趋势监控系统。

Any ideas/thoughts?任何想法/想法?

Either Lambda or EC2 would work. Lambda 或 EC2 都可以。 Those are the 2 compute resources AWS provides.这是 AWS 提供的 2 种计算资源。

This type of monitoring would normally run periodically eg once per day at noon.这种类型的监控通常会定期运行,例如每天中午一次。 For that type of monitoring, Lambda would be perfect, as it can be invoked only when needed.对于这种类型的监控,Lambda 将是完美的,因为它只能在需要时调用。

You can also launch a Ec2 instance periodically, through a scheduled event.您还可以通过计划事件定期启动 Ec2 实例。 But there is the overhead managing the server: install software and manage an AMI.但是管理服务器存在开销:安装软件和管理 AMI。

Either would work.要么会工作。 I suggest you try a prototype in Lambda.我建议你在 Lambda 中尝试一个原型。 Lambda can simplify application development and deploy at a lower cost than developing on traditional EC2 instances. Lambda 可以以比在传统 EC2 实例上开发更低的成本简化应用程序开发和部署。

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

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