Sending Custom Application Stats From EC2 Server to CloudWatch for Monitoring

In AWS, one of the common challenges that we all of us face is how to send custom application stats to CloudWatch for monitoring like we send memory, CPU, and I/O stats for automatic monitoring. I did this in one of my recent projects, and I want to share that with all of you through this article. 

This approach works fine for: