Elastic Beanstalk Memory usage monitoring with CloudWatch agent

0

With the deprecated monitoring scripts I was able to monitor memory in Elastic Beanstalk monitoring Dashboard: Add memory chart Enter image description here

Now with CloudWatch agent. I get it to report "mem_used_percent" with namespace "CWAgent", I can confirm this in Cloudwatch. I'm configuring the mem_used_percent, just as explained in the documentation: Publishing Amazon CloudWatch custom metrics for an environment

But that metric never gets listed to pick up in my Monitoring dashboard, so I can't add a chart for it.

2 Answers
0

Update 2024-01-11 Since the UI has been updated this no longer works. It looks like now Beanstalk provides a predefined set of charts and custom ones can't be added to the Monitoring panel. The only alternative is to use custom Cloud Watch dashboards.

Original answer <s> I managed to get it to work by changing the namespace to "System/Linux" (which matches what the previous monitoring scripts were sending).

This is my new configuration:

{
  ..
  "metrics": {
    "namespace": "System/Linux",
    "append_dimensions": {
      "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
      "InstanceId": "${aws:InstanceId}"
    },
    "aggregation_dimensions": [
      ["AutoScalingGroupName"],
      ["InstanceId"]
    ],
    "metrics_collected": {
      "mem": {
        "measurement": [
          { "name": "mem_used_percent", "rename": "MemoryUtilization" }
        ]
      }
   }
}

Now my dashboard shows memory graph just like before. </s>

pmoleri
answered 2 years ago
  • System/Linux Namespace in CLoudwatch is coming from the deprecated monitoring scripts.

    https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-scripts-intro.html#script_viewmetrics

  • Yes @Matt-B, it looks like Elastic Beanstalk monitoring dashboard hasn't been updated and it supports only the old namespace for memory metric. By inspecting the REST calls made by Beanstalk UI, I think there's another possible workaround that is publishing them in namespace: "AWS/ElasticBeanstalk" and add a custom dimension with the EnvironmentName within mem metric, but this is a bit more cumbersome to set up because it requires fetching the EnvironmentName during setup and manually replacing it in the config file whereas with "System/Linux" namespace it works out of the box.

0

Hi There

The custom metrics aren't going to appear in the ElasticBeanstalk console. From the documentation:

**Viewing metrics in the CloudWatch console**

After deploying the CloudWatch configuration file to your environment, check the Amazon CloudWatch console to view your metrics. Custom metrics will be located in the CWAgent namespace.

For more information, see [Viewing available metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/viewing_metrics_with_cloudwatch.html) in the Amazon CloudWatch User Guide.

You can build a CloudWatch dashboard and aggregate all of the metrics that you are interested in. See this blog post for a tutorial: https://aws.amazon.com/blogs/aws/cloudwatch-dashboards-create-use-customized-metrics-views/

In fact, CloudWatch will have an "Automatic Dashboard" already configured for your EB environment, and you can easily add your custom metrics to it.

  1. In Cloudwatch, navigate to "All Metrics" and look for Elastic Beanstalk.
  2. Hover over it and click "View Automatic Dashboard

CW Auto Dashboard

3.Then you can click "Add to Dashboard" to create your own custom dashboard for your EB app. It will copy all of the current metrics to your new custom dashboard. From there, you can add your custom metrics like mem_used_percent

Enter image description here

profile pictureAWS
EXPERT
Matt-B
answered 2 years ago
  • Thanks @mthwbarb,

    That's helpful but it feels like I'm loosing functionality when upgrading to the recommended CloudWatch Agent. I mean, having monitoring dashboard right there in the environment is an elastic beanstalk feature, and I'm loosing that for "memory" metric which is a metric that I've found very useful to monitor.

    I think I found a workaround, I'm posting a separate answer because there's a limit for comments length. I'd be grateful if you can check it out, just in case I'm screwing up something. Thanks.

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.

Guidelines for Answering Questions