Start a Project

Create Custom metrics on AWS Cloudwatch

The Cloudwatch service of AWS is very useful for developers as well as for server admins because it helps them find the bottleneck in their application architecture.

AWS provides lots of pre-defined metrics to detect the issues regarding the system and predefined services like CPU Limit, Disk Usage, Network Data, etc.

But if you want to monitor your system based on other specifications then you can achieve it with the help of custom metrics.

To create a custom metric for your system you have to use the aws cli because it helps you to put data on the cloudwatch panel.

You can download the aws cli for your OS distribution and configure it with the “aws configure” command which asks you for the following parameters-:

After installing the AWS CLI, grab the value you want to create metrics for, such as the server’s free RAM.

To grab the value of FREE RAM you can use the following bash script-:

SAVE this script with script.sh

The script includes the AWS CLI command to send data to CloudWatch. Let’s review its parameters:

Now create a crontab entry of script.sh in your server for every minute so that it will send data to Cloudwatch periodically every minute.

CRONTAB ENTRY

Now go to the cloudwatch panel and observe the graph of your metrics.

Now you can automate various tasks based on your custom metrics for ex-:

  1. You can create an alarm on Cloudwatch custom metrics to detect any abnormal activity.
  2. You can also create an alarm to autoscale your EC2 instances based on your custom metrics.

CloudWatch custom metrics let you manage server needs based on your parameters and analyze logs more efficiently with graphs.

Need Support?

Thank You for reading this Blog!

For further more interesting blogs, keep in touch with us. If you need any kind of support, simply raise a ticket at https://webkul.uvdesk.com/en/.

For further help or queries, please contact us or raise a ticket.


Exit mobile version