简体   繁体   English

CloudWatch自定义指标未按预期运行

[英]CloudWatch custom metrics not working as expected

I had already created 7 other metrics based on some log files I send to CloudWatch with no problems. 我已经毫无问题地基于发送到CloudWatch的一些日志文件创建了其他7个指标。

Some time ago we had a problem with MongoDB connection, and I identified that through logs, so I'd like to create a Metric, so that I can create an Alarm based on it. 不久前,我们遇到了MongoDB连接问题,我通过日志确定了这一点,因此我想创建一个指标,以便可以基于该指标创建警报。 I did create the Metric, but (of course) there are no data being fed into that Metic, because no more "MongoError" messages exists. 我确实创建了指标,但是(当然)没有数据被馈送到该Metic中,因为不再存在“ MongoError”消息。

But does that also mean that I can't even access the Metric to create the Alarm? 但这是否还意味着我什至无法访问“指标”来创建警报? Because this is what is happening right now. 因为这就是现在正在发生的事情。 The Metric cannot be seen anywhere, only in the "Filters" section of the Logs, which won't allow me to create Alarms or create graphics or anything. 只能在“日志”的“过滤器”部分中看不到“度量标准”,这将不允许我创建警报或创建图形或任何其他内容。

I have already posted this on AWS forums but that usually doesn't help. 我已经在AWS论坛上发布了此内容,但这通常无济于事。

An Amazon CloudWatch custom metric is only created when data is stored against the custom metric. 仅当根据自定义指标存储数据时,才会创建Amazon CloudWatch自定义指标。 Therefore, you'll need to push a data value to make appear and then you will be able to create an alarm. 因此,您需要推送一个数据值以使其出现,然后才能创建警报。

You can push some data to CloudWatch with the AWS Command-Line Interface (CLI) , eg: 您可以使用AWS命令行界面(CLI)将一些数据推送到CloudWatch,例如:

aws cloudwatch put-metric-data --namespace MongoDB --metric-name errors --value 0

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

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