Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS RDS metric for memory utilization

Does AWS RDS offer a metric for monitoring the memory utilization? I see one metric called freeable_memory which is how much available memory an instance has. I'd like to create an alert when the memory usage reaches a certain percetage of the total memory but can't seem to find a metric which supports that, similar to cpuutilization. I also found a metric called acuutilization in datadog but haven't been able to find what that metric tracks.

like image 809
Paymahn Moghadasian Avatar asked Sep 16 '25 11:09

Paymahn Moghadasian


2 Answers

Take a look at enhanced monitoring. Enhanced Monitoring has a metric called Active Memory:

The amount of assigned memory, in kilobytes.

Sounds to me like something that could be useful for you. But be aware that you also get additional costs: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.OS.overview.html#USER_Monitoring.OS.cost

like image 154
Ausgefuchster Avatar answered Sep 19 '25 07:09

Ausgefuchster


Here is what I did in Terraform to create an alarm based on percentage of utilization.

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
}
like image 22
Steveno Avatar answered Sep 19 '25 05:09

Steveno