# Memory Metrics

## Overview

Monitoring memory usage across AWS shouldn’t cost you time or money when it’s not needed. OneLens automatically turns memory metrics **on only when a policy is violated**, and turns them **off when no longer useful** - helping you stay efficient and cost-effective.

## The Problem with Memory Metrics

Memory metrics in AWS are **not enabled by default**. These are **custom metrics** that require the **CloudWatch agent** to be manually installed on each EC2 instance—and AWS charges you for every custom metric collected.

Let’s break down the numbers with an example of **10,000 EC2 instances**

* With memory monitoring enabled on all 10,000 instances, the cost adds up to:

  ```
  10,000 instances × 1 memory metric × $0.30 = $3,000 per month
  ```
* That’s around **$100 per day and $3000/month**, even if you’re not actively using the data.

{% hint style="warning" %}
Reference: [AWS CloudWatch Pricing](https://aws.amazon.com/cloudwatch/pricing/)
{% endhint %}

You’re now left with two options here:

* Keep metrics off and risk missing underutilization.
* Keep metrics on and watch your costs rise without guaranteed insights.

## What OneLens Does Uniquely

OneLens takes a smarter path by activating memory metrics **only where it matters**—based on actual policy violations.

Let’s say you have **10,000 EC2 instances**, and **200 of them** violate a policy such as “**Standalone On-Demand EC2 instances should not be underutilized**” based on only monitoring "**CPU utilization**".  OneLens automatically enables memory metrics on just those 200 instances—not all 10,000.

Here’s what happens next:

* In the **first 2 days**, suppose **150 instances** show memory usage crossing the configured threshold. OneLens disables memory metrics for those 150 immediately and will mark the ticket closed as it is confirmed that utilization is optimal.
* For the remaining **50 instances**, memory metrics continue running for the full **30-day observation period**.
  * If usage remains below the threshold for the entire 30 days, OneLens disables metrics and marks the instance as underutilized.

Then OneLens enters a second phase:

* It **waits for 30 more days** to see if the ticket is closed.
* If the ticket is still open, OneLens **re-enables memory metrics for the next 30-day cycle**, giving you fresh data.
* This loop continues until the ticket is resolved.

{% hint style="success" %}

## Benefits

By only enabling memory metrics **when triggered by policy**, and by continuously cycling based on ticket status, OneLens helps you:

* Avoid unnecessary cost
* Still get the memory data when it actually matters
* Remove the burden of tracking or managing this manually

You stay informed, without overspending.
{% endhint %}

### Setup & Enablement

Memory metrics are **enabled by default in your OneLens tenant**.

However, to start collecting data from specific AWS accounts, you’ll need to **install the memory metrics Runbook** manually in those accounts.

Learn more about [setup-metrics-collection](https://docs.onelens.cloud/integrations/memory-metrics/setup-metrics-collection "mention")


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onelens.cloud/integrations/memory-metrics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
