Are you deploying Amazon EC2 instances and want to deploy the New Relic infrastructure monitoring 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, this post is for you!

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

The great news is that deploying the New Relic infrastructure agent on an Amazon EC2 Amazon Linux instance is a quick. How quick? That depends on how fast you click. (Watch the video in the next section to see me deploy 9 instances in 23 seconds.)

Amazon Linux, provided by Amazon Web Services (AWS), is an environment for applications running on Amazon EC2.

To jump in and try out installing the New Relic infrastructure agent on just one instance, you can follow this quickstart:

linux logo

But the best news is that once you’ve launched your instances, you’ll start seeing data in New Relic within just 60 seconds.

3 ... 2 ... 1 ... launch!

There are several ways to deploy the New Relic infrastructure agent. One is to launch an Amazon 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 your path, nothing beats the sheer speed of kicking off EC2 instances yourself and deploying the latest version of the New Relic infrastructure agent simultaneously. Here’s how to do it.

First, some ground rules

  • If you don’t already have one, you’ll need a New Relic account.
  • Get your New Relic ingest-license key from API keys. Find your API keys by clicking your account name (in the lower left). Use the three dots on the right side to copy your key.
  • You’ll also need an AWS account. If you don’t have one, get one at
  • For this demo, I'll be using Amazon Linux 2. You’ll need to substitute the proper code if you are using other versions of Linux.

Basic steps

There are 5 basic steps to installing the infrastructure agent on AWS:

1. Launch an instance from the AWS Amazon EC2 console and give it a name.

2. Select Amazon Linux 2 AMI.

3. Select your options for:

  • key pair
  • network (Select a security group that allows HTTP traffic.)
  • storage

4. Open Advanced details. (This is where the magic happens.)

5. Select Launch instance to complete the process.

The magic in step 4

In step 4, where you configure the advanced details, look for a section at the bottom labeled User data. Copy and paste this short script in the User data field (don’t select base64). Then replace [YOUR_KEY] with your license key.

echo "license_key: [YOUR_KEY]" | sudo tee -a /etc/newrelic-infra.yml
sudo curl -o /etc/yum.repos.d/newrelic-infra.repo
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
sudo yum install newrelic-infra -y

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

Here’s an example with a license key of 12345:

echo "license_key: 12345" | sudo tee -a /etc/newrelic-infra.yml
sudo curl -o /etc/yum.repos.d/newrelic-infra.repo
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
sudo yum install newrelic-infra -y

Data in 60 seconds!

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

Here’s video proof of these steps. I’ve edited the video at various places to point out specific things and sped up a little as I launched the Amazon EC2 instances.

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.