Are you deploying Amazon EC2 instances and want to deploy the New Relic Infrastructure agent on them? Do you want to know the fastest, easiest way to deploy the agent? Would you like to receive data within 60 seconds? If you answered yes to any of these questions, then this post is for you!

Whether you’re in development or testing, are deploying a production instance, or just need an instance to work with for a demonstration, you’ll want to deploy the New Relic Infrastructure agent for monitoring.

The great news is that deploying the New Relic Infrastructure agent on an AWS EC2 Amazon Linux instance can be done very quickly. How quickly? That depends on how fast you click. (Watch the video below to see me deploy 9 instances in 22 seconds.)

But the best news is that once you’ve launched your instance(s), you’ll start seeing data in New Relic Infrastructure within just 60 seconds!

3 … 2 … 1 … launch!

There are several ways to deploy the New Relic Infrastructure agent. One is to launch an EC2 instance, SSH into it, and manually deploy the agent. Or you can use AWS CloudFormation to take care of everything. Or, you can even use automation tools.

Regardless of the path you choose, nothing beats the sheer speed of kicking off EC2 instances yourself and deploying the latest version of the New Relic Infrastructure agent at the same time. Here’s how to do it!

Some ground rules

  • If you don’t already have one, you’ll need a New Relic account (get one here: newrelic.com).
  • Get your New Relic Infrastructure license key (find this by going to “Account settings” in New Relic—License key displayed under “Account information” on the right).
  • You’ll also need an AWS account (if you don’t have one, get one here: aws.amazon.com).
  • We’ll be using Amazon Linux for this demonstration, you’ll need to substitute the proper code if you are using other versions of Linux.

Basic steps:

  1. From the AWS console, click the Launch Instance button.
  2. Then select Amazon Linux—General purpose.
  3. Configure Instance Details (this is where the magic happens).
  4. Go through the Storage and Tags steps (customize these as needed).
  5. Select a Security Group that allows HTTP/HTTPS (note: the default security group works).
  6. Review and click Launch to complete the process!

The Magic

In step #3 above where you are configuring the instance details, there is a section at the bottom labeled “Advanced Details.” Expand this to see a User data field. Place the short script shown below in the User data field and select “As text,” making sure to replace [YOUR_KEY] with your license key.

User data code (copy these 5 lines of code):

#!/bin/bash
echo "license_key: [YOUR_KEY]" | sudo tee -a /etc/newrelic-infra.yml
sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/6/x86_64/newrelic-infra.repo
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
sudo yum install newrelic-infra -y

Example with a license key of 12345:

#!/bin/bash
echo "license_key: 12345" | sudo tee -a /etc/newrelic-infra.yml
sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/6/x86_64/newrelic-infra.repo
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
sudo yum install newrelic-infra -y

Caution! Syntax counts. Copy/paste may modify the quote marks. If you are experiencing issues with your copy/paste, double check your single and double quotation marks.

Data in 60 Seconds!

Now, check New Relic Infrastructure. You should start seeing data in about 60 seconds.

Here is video proof of it being done. I’ve edited the video at various places to point out specific things as I launch the EC2 instances. If you just want to see it happen in real time, skip to the 1:53 mark:

It’s that fast! You’ve learned how to launch EC2 instances and have the New Relic Infrastructure agent deployed in about 90 seconds. Save the User data code with your license key to use anytime you need to launch another AWS EC2 instance.

Please feel free to share this with anyone who may need to know how fast and easy it is to deploy the New Relic Infrastructure agent to an AWS EC2 instance.

 

As a principal cloud strategist at New Relic, Kevin has deep knowledge of the cloud industry and works with customers and partners to assist in their cloud adoption journeys. He’s been in the enterprise software industry for over 21 years, and has spent 12 years as a customer facing solutions architect, selling enterprise software solutions to all verticals. View posts by .

Interested in writing for New Relic Blog? Send us a pitch!