Installing .NET Agent on Elastic Beanstalk doesn't show different servers

I’m installing the .NET Agent on ElasticBeanstalk using the follow ebextension…

source: {0}

command: msiexec.exe /i c:\newrelic\newrelic_agent.msi /q NR_LICENSE_KEY={2} INSTALLLEVEL=50

The agent is being installed correctly, but it is show a single server for all the different applications. Is there a way to specific the ec2 hostname via the AWS EC2 meta-data instead of going off the machine’s hostname which is out of my control due to elastic beanstalk?

Hey there @richard_reedy

Normally, you cannot have two servers with the same hostname on a network or in a domain. Within AWS you can have more than one server with the same name. If you use an AMI as the base for a server and do not change the hostname either manually or via sysprep all servers from that AMI will have the same name. This leads to servers running WSM all reporting to the same entry on the dashboard.

You might be able to automate this process and set up the host name when the instance boots using these instructions:

Otherwise, while we don’t recommend this because you will break the linkages between an application’s reported host name in the APM and the actual server, you can change the reported host name via a registry key. Here is how:

Open the registry editor:

  1. Browse to : HKEY_LOCAL_MACHINE\SOFTWARE\New Relic\Server Monitor.
  2. Add or Update the Host string with a new value.
  3. Restart the New Relic Windows Server Monitor Service.

Hopefully this helps!

Thanks! I’m working on changing the hostname on the instance. But so far, I’m not having any luck changing the hostname on the EC2 instance and having New Relic pick up the new hostname. It looks like it is still picking up the hostname.

For the .NET agent, how do you pull the hostname? At this point, I think I have to manually change the registry to reflect the name without doing a restart on the instance.

Also, I’m only installing the .NET Agent, should I be installing the .NET Agent and the Server Monitor for the same machine or does the .NET agent do the same things as the Server Monitor?

Hi Richard,
Did you have any luck with this? We are having the same problem…


No, I’m not having much luck on my side.

I’ll share what I have in my newrelic.config that is in the ebextensions folder. I’m able to install the new relic agent, just working on getting the hostnamed change.

Talking with Amazon support, I have to restart the instance which I’m working on. Also, trying to get logging working so that I can see and verify the hostname change.


    source: {0}
     content: |
       Write-Eventlog -LogName Application -Source Ec2Config -EventId 1000 -EntryType Information -Message ""Changing hostname""
       $newHostName = $(invoke-restmethod -uri".") | select -First 1
       Write-Eventlog -LogName Application -Source Ec2Config -EventId 1000 -EntryType Information -Message $(""Pre .NET GetHostName: "" + $([System.Net.Dns]::GetHostName()))
       Write-Eventlog -LogName Application -Source Ec2Config -EventId 1000 -EntryType Information -Message $(""Expected HostName: "" + $newHostName)
       Rename-Computer -Force -NewName $newHostName
       Write-Eventlog -LogName Application -Source Ec2Config -EventId 1000 -EntryType Information -Message $(""Post.NET GetHostName: "" + $([System.Net.Dns]::GetHostName()))        
     command: powershell.exe -ExecutionPolicy Bypass -Command "c:\\init_scripts\\change_hostname_in_config.ps1"
     waitAfterCompletion: 0
     command: msiexec.exe /i c:\\newrelic\\newrelic_agent.msi /q NR_LICENSE_KEY={1} INSTALLLEVEL=50
     waitAfterCompletion: 0

EDITED: Updated with EventLogging that will show in logs

@richard_reedy -

Thanks for all your work so far! It looks like you’ve invested a lot of time so far.

I don’t know if this will be helpful but the .NET agent uses the following call to get the host name: System.Net.Dns.GetHostName() . So I hope there is a way affect that from the AWS side.

Unfortunately, there is not an agent configuration setting to cause it to report a different host name (the registry key change only applies to the server monitor agent). That might make a good feature request (which I would be glad to make).

If we discover anything ourselves we will be sure to post and we look forward to any discoveries you might make.