This document explains the steps taken to implement New relic and AWS infra monitoring on prod2 resources.
New relic instructions
For setting up in ECS:
Download the new relic java agent zip file and extract it from the new relic docs : https://docs.newrelic.com/docs/agents/java-agent/installation/install-java-agent
configure the agent with newrelic.yml file and add the add the license key and app name as per the instructions in the above link.
Place the new relic folder inside the docker folder.
Copy the new relic in to the app.Dockerfile by adding the following lines.
COPY docker/newrelic /opt/jboss/wildfly/newrelicAdd the java arguments in the docker-compose.yml in order to make the new relic agent work.
JAVA_OPTS: "-javaagent:/opt/jboss/wildfly/standalone/newrelic/newrelic.jar"Then build the by using the docker-compose up app (for more info on building image refer : prod2 documentation)
Once the image is built and tested push it to ECR and restart the ECS service based on prod2 documentation.
Create a revision of the task-definition and add the java argument in the environment section of the app container.
For setting up in Solr:
Download the java agent for solr with
curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zipExtract the zip file and configure the newrelic.yml with the license key and application name.
Set the java argument for solr based on the version of solr.
#for Standalone Solr 5.x or higher
SOLR_OPTS="$SOLR_OPTS -javaagent:/full/path/to/newrelic.jar"
#for Standalone Solr 4.x or lower
java -javaagent:/full/path/to/newrelic.jar -jar start.jar(Reference : https://docs.newrelic.com/docs/agents/java-agent/installation/include-java-agent-jvm-argument#Installing_on_solr)
Once it is setup restart the solr application to get data into newrelic APM.
For setting up in Batch server:
Download the new relic java agent inside the batch server with
curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zipExtract the zip file and configure the newrelic.yml with the license key and application name.
Set the java argument for batch server in the batchstarter.sh
-javaagent:/full/path/to/newrelic.jarAWS Cloudwatch agent setup for infrastructure monitoring:
For setting up cloudwatch agent:
SSH into the instance.
Download the cloudwatch agent from the link below
Download and install the perl modules.
Download and Install the monitoring script.
#To download the cloudwatch script
curl https://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.2.zip -O
#Install the scripts
unzip CloudWatchMonitoringScripts-1.2.2.zip && \
rm CloudWatchMonitoringScripts-1.2.2.zip && \
cd aws-scripts-monCreate a cronjob to make the script run for every 5 minutes
crontab -e
#Add the line to the crontab
*/5 * * * * ~/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-util --disk-space-util --disk-path=/ --from-cronThis should install the cronjob and the agent will begin reporting data.
To enable the CloudWatch agent to send data from the instance, we must attach an IAM role to the instance. The role to attach is CloudWatchAgentServerRole.