问题描述
我看到AWS RDS提供了一个 FreeStorageSpace
指标来监视磁盘使用情况.现在,我正在尝试为我的所有RDS创建 or indirectly).
更新
由于事实已经确定, FreeStorageSpace
是RDS提供的唯一与磁盘存储有关的度量标准,因此有关是否/如何为 TotalStorageSpace
建立自定义度量标准的任何想法还是 UsedStorageSpace
?
Since the fact is established that FreeStorageSpace
is the only metric RDS provides related to disk storage, any ideas on if / how we can we build a custom metric for TotalStorageSpace
or UsedStorageSpace
?
p.s .:为每个RDS创建单独的警报以评估磁盘使用百分比似乎浪费了时间和资源.
p.s.: Creating separate alarms for each RDS for evaluating disk usage percentage seems such waste of time and resource.
推荐答案
如果启用增强监控,然后Cloudwatch Logs中的RDSOSMetrics日志组将具有包含文件系统统计信息的详细JSON日志消息.我最终创建了Cloudwatch Logs指标过滤器,以从根文件系统的 fileSys
属性中解析出 usedPercent
值.至少对于Postgresql而言,这些详细的日志包括/
和/rdsdbdata
文件系统.后者是在存储空间方面令人感兴趣的.
If you enable Enhanced Monitoring, then the RDSOSMetrics log group in Cloudwatch Logs will have detailed JSON log messages which include filesystem statistics. I ended up creating a Cloudwatch Logs metric filter to parse out the usedPercent
value from the fileSys
attribute for the root filesystem. At least for Postgresql, these detailed logs include both /
and /rdsdbdata
filesystems; the latter is the one that is of interest in terms of storage space.
您可以创建格式为 {$.instanceID =" My_DB_Instance_Name"&&$ .fileSys [0] .mountPoint ="/rdsdbdata"}
和相应的指标值 $.fileSys [0] .usedPercent
,以获取给定实例的已用存储百分比.然后,它将用作可用于触发警报的日志指标.您可能需要创建另一个度量标准,用 filesystem [1]
替换 filesystem [0]
,因为该数组的排序未知.您可能想要为每个RDS实例创建这些实例,以便知道哪个RDS实例空间不足,但是您的问题似乎表明您不希望每个实例都发出警报.
You can create a metric filter of the form {$.instanceID = "My_DB_Instance_Name" && $.fileSys[0].mountPoint = "/rdsdbdata"}
and a corresponding metric value $.fileSys[0].usedPercent
to get the used storage percentage for a given instance. This would then be available as a Log Metric that you could use to trigger an alarm. You probably need to create another metric replacing filesystem[0]
with filesystem[1]
since ordering is unknown for that array. You'd probably want to create these for each RDS instance you have so you know which one is running out of space, but you question seems to indicate you don't want a per-instance alarm.
我想您可以从指标过滤器中排除 $.instanceID
,而只需将所有值写入一个指标即可.当达到阈值并触发警报时,您需要开始检查以查看哪个实例负责.
I suppose you could exclude the $.instanceID
from the metric filter and just get all values written to a single metric. When it reached a threshold and triggered an alarm, you'd need to start checking to see which instance is responsible.
这篇关于如何从AWS RDS获取TotalStorageSpace或UsedStorageSpace指标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!