Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

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

.net
aws

#1

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

files:
““c:\newrelic\newrelic_agent.msi””:
source: {0}

commands:
01_install_newrelic_agent:
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?


#2

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:

http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/UsingConfig_WinAMI.html

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!


#3

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?


#4

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

Ed.


#5

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.

newrelic.config

files:
  "c:\\newrelic\\newrelic_agent.msi":
    source: {0}
  "c:\\init_scripts\\change_hostname_in_config.ps1":
     content: |
       Write-Eventlog -LogName Application -Source Ec2Config -EventId 1000 -EntryType Information -Message ""Changing hostname""
       $newHostName = $(invoke-restmethod -uri http://169.254.169.254/latest/meta-data/hostname).Split(".") | 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()))        
 commands:
   01_change_hostname:
     command: powershell.exe -ExecutionPolicy Bypass -Command "c:\\init_scripts\\change_hostname_in_config.ps1"
     waitAfterCompletion: 0
   02_install_newrelic_agent:
     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


Feature Idea: Custom hostname configuration in newrelic.config
#6

@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.