Last active
March 29, 2017 17:20
-
-
Save svenvarkel/0cb7d53139eb0258640c65bd4542ef6b to your computer and use it in GitHub Desktop.
Configure tag Name as hostname for New Relic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
"/opt/elasticbeanstalk/hooks/appdeploy/post/60_configure_newrelic_hostname.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash | |
set -xe | |
export EC2_TAG_NAME=$(/opt/aws/bin/ec2-describe-tags --filter "resource-type=instance" --filter "resource-id=$(/opt/aws/bin/ec2-metadata -i | cut -d ' ' -f2)" --filter "key=Name" | cut -f5) | |
sed -i "s/#hostname=.*/hostname=$EC2_TAG_NAME/" /etc/newrelic/nrsysmond.cfg | |
/etc/init.d/newrelic-sysmond restart | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added to .ebextensions/00_configure_newrelic_hostname.config file. The script will be executed upon app deployment and it would register EC2 tag "Name" as hostname at New Relic. By default it's a dynamic IP address and it's very hard to distinguish between different servers.