Friday, April 26, 2013

Configuring NewRelic on Amazon Elastic BeanStalk

NewRelic is one of the most popular Application Performance Management tool used in Amazon Web Services to monitor applications . It supports most of the popular programming languages like Java,.Net,PHP,Ruby, Python etc. You can perform Server Monitoring,SQL/NoSQL performance monitoring,Web application transaction tracing etc using NewRelic in AWS infra. 

Amazon Elastic BeanStalk is a service that helps you to quickly deploy and manage applications in the AWS cloud. NewRelic+ BeanStalk is a popular combination in AWS. In this article we are going to explore how to configure NewRelic in Amazon Elastic BeanStalk for Java application deployed in Tomcat-7 container.

Step 1: Sign up and download the files
Sign up in the New Relic site with URL http://newrelic.com/signup
On successful sign up New Relic will provide customized newrelic.yml file by logging into https://rpm.newrelic.com.
Click the "Account settings" in upper right corner and then Click on the "Download the latest agent" link for Java to download the files you'll need.
The newrelic_agent2.16.0.zip will contain the newrelic.jar and the newrelic.yml

Step 2: Building Application with New Relic Agent:
Add the newrelic.jar and newrelic.yml  into WEB-INF/lib/ folder of your application war.
Repackage the war file. e.g., sample file name Newpet.war

Step 3: Uploading the new build into Amazon Elastic Beanstalk
Upload the repackaged jar to the Elastic BeanStalk using the tab “version” under the Elastic Beanstalk application details.
Once the upload is successful. It will be listed under the versions.
Choose "upload but do not deploy to any environment" option as illustrated in below diagram



Step 4: Launch the newly uploaded version 
Use the “Launch New Environment” to launch the new application version. Under the version select the latest upload version and then select the Container type as required. In this case the container is 64bit Amazon Linux running Tomcat 7.  


Follow the below steps , Choose the Instance type for your Web/App tier(t1.micro in this sample) . For customer facing production sites, it is recommended to start this with m1.large instance type.




and finally review and finish the setup as shown below.


Check the running instances in the AWS console

Step 5: Activate agent in AWS JVM configuration
Go to your "Petclinic" application environment and click the "Environment Details" and then go to the "Overview" tab. Click on "Edit Configuration" as seen below :


Click on your Container tab and enter the following in the "JVM Command Line Options" field as illustrated below:
-javaagent:/var/lib/tomcat7/webapps/ROOT/WEB-INF/lib/newrelic.jar



Note: This path is only accurate for the Tomcat7 container. You will need to alter the path accordingly based on your container requirements.

Click on "Apply Changes". The JVM will re-start and the application should start appearing in your New Relic account console within few minutes.

Step 5: Check Application status in New Relic Dashboard
You can see the Application status in the New Relic Dashboard as below

Since we had launched 3 EC2 instances in our Amazon Elastic BeanStalk tier you can see 3 servers listed for monitoring in the NewRelic Dashboard.

NewRelic charges your credit card each month/year for a specified number of servers associated to your account. A server/host is an Amazon EC2 instance running in AWS(in our context). Since EC2 instances have unique host names, NewRelic  distinguishes them easily .In our case ip-10-X.X.X listed in the above picture are EC2 instance host names. You can change the number of EC2 instance associated to NewRelic at any time and your billing will adjust with your next month.

In our case upto 5 EC2 instances are allowed for this NewRelic Account. So if Auto Scaling is enabled in Amazon Elastic BeanStalk and it scales out from 3->5 EC2 instances, they will still be automatically registered and monitored in NewRelic console. No additional configuration is needed. When more than 5 EC2 are launched, additional ones will not be shown in the NewRelic console until you upgrade your NewRelic plan. This simple SaaS licensing model and easy integration with Tomcat JVM makes NewRelic, a popular choice in AWS infra.

Now you can start monitoring and analyzing how your Web/App performs in deep using the NewRelic Dashboard.
















No comments:

Need Consulting help ?

Name

Email *

Message *

DISCLAIMER
All posts, comments, views expressed in this blog are my own and does not represent the positions or views of my past, present or future employers. The intention of this blog is to share my experience and views. Content is subject to change without any notice. While I would do my best to quote the original author or copyright owners wherever I reference them, if you find any of the content / images violating copyright, please let me know and I will act upon it immediately. Lastly, I encourage you to share the content of this blog in general with other online communities for non-commercial and educational purposes.

Followers