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, this post is for you!
This blog post first appeared on the New Relic blog, on September 25th, 2027, and updated on November 4th, 2022.
By Kevin Downs, Solutions Strategy Director
Whether you’re in development or testing, deploying a production instance, or needing 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 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:
NEW RELIC AMAZON LINUX INTEGRATION
Start monitoring your Amazon Linux data today.
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
- You’ll need a New Relic account if you don’t already have one.
- 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 aws.amazon.com.
- 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.
#!/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/amazonlinux/2/x86_64/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:
#!/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/amazonlinux/2/x86_64/newrelic-infra.repo
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
sudo yum install newrelic-infra -y
Infrastructure agent 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.
Next steps
Feel free to share this with anyone who needs to know how fast and easy it is to deploy the New Relic infrastructure monitoring agent to an Amazon EC2 instance.
Curious about other tips for infrastructure monitoring? Check out our Getting started with infrastructure monitoring documentation. Interested in more AWS integrations? Read about detecting and responding to events in Amazon Cloudwatch Metric Streams.
If you’re not already using New Relic, get started with New Relic for free. Your free account includes 100 GB/month of free data ingest, one free full-access user, and unlimited free basic users.