AWS RDS 是否提供监控内存利用率的指标?我看到一个名为
freeable_memory
的指标,它是实例拥有多少可用内存。我想在内存使用量达到总内存的一定百分比时创建警报,但似乎找不到支持该警报的指标,类似于 cpuutilization
。我还在 datadog 中发现了一个名为 acuutilization
的指标,但一直无法找到该指标跟踪的内容。
查看增强监控。增强监控有一个名为 Active Memory:
的指标分配的内存量(以千字节为单位)。
对我来说听起来可能对你有用。但请注意,您还会产生额外费用: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.OS.overview.html#USER_Monitoring.OS.cost
这是我在 Terraform 中所做的。
resource "aws_cloudwatch_metric_alarm" "rds_memory_utilization" {
alarm_name = format("RDS-MemoryUtilization-%s-%s", var.env, var.identifier)
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.memory_evaluation_periods
threshold = var.memory_threshold
datapoints_to_alarm = var.memory_datapoints_to_alarm
treat_missing_data = "notBreaching"
alarm_description = format("%s-%s %s%% memory utilization", var.env, var.identifier, var.memory_threshold)
actions_enabled = "true"
alarm_actions = [data.aws_sns_topic.ops_sns.arn]
ok_actions = [data.aws_sns_topic.ops_sns.arn]
metric_query {
id = "percent_memory_utilization"
label = "percent_memory_utilization"
# need to convert rds_total_memory to bytes first, get the percentage of available memory and then subtract to calculate the memory utilization
expression = "100 - ((m1/(${var.rds_total_memory}*1048576))*100)"
return_data = "true"
}
metric_query {
id = "m1"
metric {
metric_name = "FreeableMemory"
namespace = "AWS/RDS"
period = var.memory_period
stat = "Maximum"
dimensions = {
DBInstanceIdentifier = var.identifier
}
}
}
provider = aws.env
}