Skip to content

How to query RDSOS enhanced monitoring in Cloudwatch to view memory usage for more than 1 hour?

0

Enhanced monitoring view from RDS only allow up to 1 hour ago. I want to view active/inactive rds memory usage over last month. I'm not sure what's the best approach for this? I found RDSOS metrics doc but not sure how to formulate a query with "group" involved. Thanks!

2 Answers
0

To view RDS Enhanced Monitoring metrics, including memory usage, for more than 1 hour (in your case, over the last month), you can use Amazon CloudWatch Logs. Here's how you can approach this:

  1. First, ensure that Enhanced Monitoring is enabled for your RDS instance. This will send the OS-level metrics to CloudWatch Logs.

  2. The Enhanced Monitoring metrics are stored in CloudWatch Logs under the log group named "RDSOSMetrics".

  3. To query these metrics:

    • Open the CloudWatch console
    • In the navigation pane, select "Logs"
    • Find and choose the "RDSOSMetrics" log group
    • Locate the log stream that corresponds to your RDS instance (it will be identified by the DbiResourceId of your instance)
  4. Once you've found the correct log stream, you can use CloudWatch Logs Insights to query the data. Here's an example query to get memory usage:

    fields @timestamp, @message
    | filter @message like /memory/
    | parse @message "* * * * * * * * * * * * * * * * * * * * * *" as timestamp, instance_id, memory_total, memory_active, memory_inactive, memory_free, memory_cached
    | display timestamp, memory_total, memory_active, memory_inactive, memory_free, memory_cached
    | sort @timestamp desc
    | limit 1000
    
  5. You can adjust the time range for your query to cover the last month.

This approach allows you to view and analyze the memory usage data for your RDS instance over an extended period. You can modify the query to focus on specific memory metrics (active, inactive, free, cached) as needed.

Additionally, if you want to create visualizations or set up more advanced monitoring, you could consider importing these metrics into CloudWatch metrics. This would allow you to create dashboards, set up alarms, and perform more complex analyses. However, this approach would require additional setup and may incur extra costs.
Sources
Import Amazon RDS Enhanced Monitoring metrics into Amazon CloudWatch | AWS Database Blog
Viewing OS metrics using CloudWatch Logs - Amazon Relational Database Service
Setting up and enabling Enhanced Monitoring - Amazon Relational Database Service

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Hello.

You can check it by querying CloudWatch Logs Insights as re:Post Agent answers, but you can also register it as a metric using the Cloudwatch Logs metric filter.
If you can register it as a metric, you can also set alarms, so it is recommended.
https://repost.aws/knowledge-center/custom-cloudwatch-metrics-rds

By the way, if you run the query answered by re:Post Agent, an error will occur, so when you actually query with CloudWatch Logs Insights, you can retrieve only memory information by doing the following.

filter @logStream = 'db-yyyyyyyyy'
| fields @timestamp, memory.total as total_memory, 
         memory.active as active_memory,
         memory.inactive as inactive_memory,
         memory.free as free_memory,
         memory.cached as cached_memory
| sort @timestamp desc
| limit 1000
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.