🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to enable Deployment history in Newrelic?

The deployments resource allows for querying, creating and deleting deployment records for an application.

Deployment history

NewRelic Deployments feature reveals the impact of deployments on your application’s performance. You’ll quickly see whether the deployment had a positive or negative impact on CPU, memory, response time, throughput, database activity, or errors.

New Relic Pro customers can come here to see details of their application deployment history, including:

  • Date & time
  • Revision number
  • Aggregate metrics for the deployed code:
  • Apdex score
  • CPU usage
  • Memory usage
  • Response time
  • Throughput
  • Error rate

How to track enable deployments with New Relic?

Send deployment information from the Java agent jar file?

$ java -jar newrelic.jar deployment DEPLOYMENT_OPTIONS
$ echo "get SHA-1 34837888734" | java -jar newrelic.jar deployment DEPLOYMENT_OPTIONS --changes
$ java -jar newrelic.jar deployment user=$deployed_by revision=$deployment_versioncat
$ change.log | java -jar newrelic.jar deployment --changes --revision="Summer Sale Event"

Send deployment information directly via HTTPS

This API endpoint creates a deployment record for a given application. Deployment records are created with the following attributes:

Required:

  • Application ID
  • Revision, such as a git SHA

Optional:

  • Changelog
  • Description
  • User posting the deployment
  • Timestamp of the deployment

Request

curl -X POST 'https://api.newrelic.com/v2/applications/{application_id}/deployments.json' \
     -H 'X-Api-Key:{api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "deployment": {
    "revision": "string",
    "changelog": "string",
    "description": "string",
    "user": "string"
  }
}' 

Sample Script for Generating a data and Adding Deployment

#!/bin/sh

# Variables
WAR_FILE_V1="petclinic-1.0.war"
WAR_FILE_V2="petclinic-2.0.war"
HOST_NAME="13.234.21.228"
PORT="80"

AWS_KEY_FILE="./rajesh-mumbai.pem"
AWS_EC2_INSTANCE="ubuntu@${HOST_NAME}"

APP_URL="http://${HOST_NAME}:${PORT}/petclinic/"
NR_API_KEY="NRRA-8be5d1f42ee92bcaccdce4675b6cdcc5842f0d0c3e"
NR_APP_ID="294580546"

NR_DEPLOY_CHANGELOG_V1="Initial deploy"
NR_DEPLOY_CHANGELOG_V2="Replaced dandelion datatables with jQuery, removed session state caching"
NR_DEPLOY_DESC_V1="v1.0"
NR_DEPLOY_DESC_V2="Upgrade to v2.0"
NR_DEPLOY_REVISION_V1="2738cbdcca"
NR_DEPLOY_REVISION_V2="3d2d67bbfb"
NR_DEPLOY_USER="Rajesh Kumar"

JMETER_SCRIPT="aws.jmx"

deployApp ()
{
	# Copy WAR file to webapps folder
	echo "\n--- Deploying" $1 "\n"
	scp -i $AWS_KEY_FILE ./$1 $AWS_EC2_INSTANCE:~/webapps/petclinic.war
	
	# Set deployment marker
	deploymentMarker "$2" "$3" "$4"
	
	# Restart Docker container
	echo "\n--- Restarting petclinic container"
	ssh -i $AWS_KEY_FILE $AWS_EC2_INSTANCE 'sudo docker restart petclinic'
	
	# Wait for app restart
	echo "\n--- Waiting for app restart"
	sleep 30
	while [ $(curl -s -o /dev/null -I -w "%{http_code}" $APP_URL) -ne 200 ] ; do
		printf "."
	done
	echo
	return
}

deploymentMarker ()
{
	echo "\n--- Setting deployment marker\n"

    curl -X POST "https://api.newrelic.com/v2/applications/${NR_APP_ID}/deployments.json" \
         -H "X-Api-Key:${NR_API_KEY}" -i \
         -H 'Content-Type: application/json' \
         -d \
        "{
            \"deployment\": {
                \"revision\": \"${2}\",
                \"changelog\": \"${3}\",
                \"description\": \"${1}\",
                \"user\": \"${NR_DEPLOY_USER}\"
            }
        }"

	return
}

startJmeter ()
{
	# Start JMeter script
	/c/tools/apache-jmeter-5.3/bin/jmeter -n -JHOST=${HOST_NAME} -JPORT=${PORT} -t $1
	return
}

deployApp "$WAR_FILE_V1" "$NR_DEPLOY_DESC_V1" "$NR_DEPLOY_REVISION_V1" "$NR_DEPLOY_CHANGELOG_V1"
echo "\n--- Starting Jmeter. Wait 10-15 minutes, then run thread profiler\n"
startJmeter "$JMETER_SCRIPT"

# After 10-15 minutes, start thread profiler

# When Jmeter script completes, deploy v2 and repeat
deployApp "$WAR_FILE_V2" "$NR_DEPLOY_DESC_V2" "$NR_DEPLOY_REVISION_V2" "$NR_DEPLOY_CHANGELOG_V2"
echo "\n--- Starting Jmeter. \n"
startJmeter "$JMETER_SCRIPT"

Reference
https://rpm.newrelic.com/api/explore/application_deployments/create

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.