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.

1COPY docker/newrelic /opt/jboss/wildfly/newrelic
  •  Add the java arguments in the docker-compose.yml in order to make the new relic agent work.

1JAVA_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

1curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip
  • Extract 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.

1#for Standalone Solr 5.x or higher 2SOLR_OPTS="$SOLR_OPTS -javaagent:/full/path/to/newrelic.jar" 3 4#for Standalone Solr 4.x or lower 5java -javaagent:/full/path/to/newrelic.jar -jar start.jar

For setting up in Batch server:

  • Download the new relic java agent inside the batch server with

1curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip
  • Extract 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

1-javaagent:/full/path/to/newrelic.jar


AWS Cloudwatch agent setup for infrastructure monitoring:

For setting up cloudwatch agent:

1#To download the cloudwatch script 2curl https://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.2.zip -O
1#Install the scripts 2unzip CloudWatchMonitoringScripts-1.2.2.zip && \ 3rm CloudWatchMonitoringScripts-1.2.2.zip && \ 4cd aws-scripts-mon
  • Create a cronjob to make the script run for every 5 minutes

1crontab -e 2#Add the line to the crontab 3*/5 * * * * ~/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-util --disk-space-util --disk-path=/ --from-cron
  • This 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.