Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to add New Relic to an AWS Elastic Beanstalk EC2 for .NET without creating a custom AMI.

Add New Relic To Elastic Beanstalk for .NET

The instructions and files in this Gist can be used to configure an EC2 instance to install both the New Relic .NET Agent and Server Monitor on an EC2 deployed inside of an Elastic Beanstalk, without creating a custom AMI. Once configured, EC2s will begin reporting application and server metrics automatically to New Relic, even as the Elastic Beanstalk scales up and adds more EC2s.


  1. Create a top-level directory in your source bundle called .ebextensions and add newrelic.config to it.
  2. Change the values in newrelic.config to match your configuration, where:
    • download_path_to = URL to download the PowerShell script and New Relic Agents (e.g. an S3 bucket)
    • platform = choose the installer appropriate for your system (i.e. x86 or x64)
    • version = the latest version of the New Relic Agent
    • new_relic_license_key = your New Relic license key
  3. Add an application setting to your application's configuration (i.e. web.config) named NewRelic.AppName, and set its value to the name of the application.
  4. Deploy your application to Elastic Beanstalk.


  • The EnableEc2SetComputerName.ps1 PowerShell script configures the EC2 instance to use a unique computer name based off their private IP address. This allows each server to be reported independently of other EC2 instances sending data to New Relic. Without configuring unique names, EC2s will appear as a single server in NewRelic. This modification to the EC2 requires a reboot.


$EC2SettingsFile="C:\Program Files\Amazon\Ec2ConfigService\Settings\Config.xml"
$xml = [xml](get-content $EC2SettingsFile)
$xmlElement = $xml.get_DocumentElement()
$xmlElementToModify = $xmlElement.Plugins
foreach ($element in $xmlElementToModify.Plugin)
if ($ -eq "Ec2SetComputerName")
source: http://<download_path_to>/EnableEc2SetComputerName.ps1
source: http://<download_path_to>/NewRelicAgent_<platform>_<version>.msi
source: http://<download_path_to>/NewRelicServerMonitor_<platform>_<version>.msi
command: powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\\Public\\Downloads\\EnableEc2SetComputerName.ps1"
command: msiexec.exe /i "C:\\Users\\Public\\Downloads\\NewRelicAgent.msi" /qb NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50
command: msiexec.exe /i "C:\\Users\\Public\\Downloads\\NewRelicServerMonitor.msi" /L*v install.log /qn NR_LICENSE_KEY=<new_relic_license_key>
command: powershell.exe -Command "Restart-Computer"
<add key="NewRelic.AppName" value="Your Application Name Here"/>

This comment has been minimized.

Copy link

@r0n22 r0n22 commented Sep 25, 2013

I am trying to use this system.

I am getting New Relic installed but the actual application does not deploy.

I am getting in the event log:

  • Failed to deploy application.
  • Some instances have not responded to commands. Responses were not received from [XXXXXXX]

I am very new with AWS and Beanstalk.

Could you shed any light on how to fix this?


This comment has been minimized.

Copy link

@tucaz tucaz commented Oct 26, 2013

@r0n22 take a look at the logs. In my case that happened due to lack of permissions to access the s3 bucket where the installers were. I made them public and that did the job. It's working.


This comment has been minimized.

Copy link

@tuler tuler commented Feb 27, 2015


This comment has been minimized.

Copy link

@mishabar mishabar commented Feb 28, 2015

will this reinstall the newrelic agents and reboot the servers every time i redeploy the application ?


This comment has been minimized.

Copy link

@robbileifss robbileifss commented Jan 11, 2016

How can I have this not execute on my dev but only on my prod beanstalk ? I am publishing thru my visual studio btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment