To set this up you will need to do the following:
- Have an AWS account
- Set up a IAM Role to be applied to a running instance which you want to monitor
- Start EC2 instance hosting Tomcat which has outbound access to the internet
- Download the AWS CLI package
- Create a script to extract the JVM stats and publish to CloudWatch using the CLI
- Set execution of the script in cron to publish the metrics at your desired frequency
Assuming you already have an AWS account and know your way around, create an IAM role which will be assigned to the EC2 instance you want to monitor. This should allow applications on the instance to manage metric data
Launch an instance into the subnet as usual and assign the new IAM role. If you already have a base image containing a tomcat installation then use that. Otherwise, install tomcat as you wish. I won't cover this in this post. Once running open a session and install the AWS CLI package.
You can confirm the installation is good by running aws help which will show the manual. Now create a script to get the JVM stats from your running tomcat instance and use the CLI to send to CloudWatch. You may well want to run this on multiple instances so it makes sense to ascertain the instance id at runtime and use this when you define the metric name in the CLI command. To discover the instance id you'll need to make an HTTP request and interrogate the meta data, assign this to a variable in your script which will be used in the CLI command later.
Locate the catalina PID file which contains the process ID of your running Tomcat instance. Depending on your version and installation this can be in various places. The PID file contains the id of the running Tomcat process. There are various other ways you could ascertain this using the jps or ps commands.
Use the jstat command to print a snapshot of the JVM memory performance statistics. These are pretty printed so there has to be a bit of String manipulation to pick them out. Use the AWS CLI command to invoke the CloudWatch service which makes a PUT request with the substituted data. In the example below I've created a metric name for each jstat value from this EC2 instance, identified by the instance id. Here's the full script -
It's then a simple case of adding this script to a cron schedule. You'll then be able to login to the AWS console, navigate to CloudWatch and select the metrics. From here, you can easily create the alarms and notifications for different threshold values of the metric data.
Thanks John for the details its Informative
ReplyDeleteHi John,
DeleteSuch vivid info on the Custom CloudWatch Tomcat JVM Metrics! Flabbergasted! Thank you for making the read a smooth sail!
I am new to Linux, and I am hoping to have just a leisurely conversation about switching from windows. I will find answers to specific questions hopefully with a search here, but I may still ask anyway.
Excellent tutorials - very easy to understand with all the details. I hope you will continue to provide more such tutorials.
Thank you,
Kevin
Thank you, this helped a lot.
ReplyDeletehi John,
ReplyDeleteI need to develop similar solution in Windows.
Please if you can help
Really nice blog provided by you thanks for providing your information. For more updates AWS Online Training Hyderabad Get Trained and Get Job
ReplyDeleteSuperb
ReplyDeleteSAP Training in Chennai
SAP ABAP Training in Chennai
SAP Basis Training in Chennai
SAP FICO Training in Chennai
SAP SD Training in Chennai
SAP MM Training in Chennai
SAP PM Training in Chennai
SAP PP Training in Chennai
SAP MDG Training in Chennai
SAP EHS Training in Chennai
It was really fun reading ypur article. Thankyou very much. # BOOST Your GOOGLE RANKING.It’s Your Time To Be On #1st Page
ReplyDeleteOur Motive is not just to create links but to get them indexed as will
Increase Domain Authority (DA).We’re on a mission to increase DA PA of your domain
High Quality Backlink Building Service
Boost DA upto 15+ at cheapest
Boost DA upto 25+ at cheapest
Boost DA upto 35+ at cheapest
Boost DA upto 45+ at cheapest
David Forbes is president of Alliance Marketing Associates IncIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder
ReplyDeleteaz 104 exam questions
ReplyDeletescrum master exam questions
dp 900 exam questions
da 100 exam questions
Letter commercial create remember issue. Mrs beyond go like kitchen. Including report official not.health
ReplyDeleteBravo! Your article was a pleasure to read. The real-life examples you shared made it easy to grasp the concepts. Also, it's great to see you promoting responsible trading practices. Speaking of which, does Radhe exchange user IDoffer any risk management tools?
ReplyDelete"Your blog has given me such insightful information on the subject that it has deepened my understanding. Thank you for sharing!"
ReplyDeleteSAP Analytics Cloud Training
"I really enjoyed reading your blog post; it was very well-written and extremely informative."
ReplyDeleteSalesforce CPQ Certification
"I appreciate you sharing such a useful topic.
ReplyDeleteSalesforce CPQ Course
I adored your blog post very much! Your observations are so insightful and energizing. It's obvious that you spent a lot of time and effort writing and researching this essay. Your writing is interesting and simple to read, making even difficult subjects seem understandable. Readers like myself who are looking for insightful and well-informed information appreciate you sharing your expertise and viewpoint on this subject. Hopefully you'll write more informative stuff in the future. Continue your excellent job!
ReplyDeleteSalesforce CPQ Training
I appreciate you spending the time to share your knowledge and skills. You have not only increased my knowledge of subject but also my interest in it. Keep up the great work, and I'm looking forward to your upcoming posts!
ReplyDeleteGolang Certification
Great great post; it definitely improved my understanding of the subject.
ReplyDeleteGolang Course
"I couldn't agree more with your points; this blog really opened my eyes to new ideas!
ReplyDeleteMulesoft Course
"Great post, I found it to be really insightful and stimulating!"
ReplyDeleteCCSP Training
"I totally concur with your points; this blog post is spot on!"
ReplyDeleteCCSP Certification
Go India Tour and Cabs leads in providing Taxi service in Jaipur that offers the most luxurious and reasonably priced taxi trips in world-class vehicles. We offer cab in Jaipur travel, outstation trips, weddings, corporate events, airport services, and sightseeing in Jaipur.
ReplyDelete