Created
January 27, 2017 20:04
-
-
Save MrCoffey/702c6f4dd9852df7f182b9dfc2793944 to your computer and use it in GitHub Desktop.
Newrelic configuration for elasticbeanstalk
This file contains 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/pre/01-get-env-name.py": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/usr/bin/env python | |
# https://steelpangolin.wordpress.com/2015/01/30/how-to-find-the-name-of-an-elastic-beanstalk-environment-from-inside-one-of-its-instances/ | |
import boto.utils | |
import boto.ec2 | |
iid_doc = boto.utils.get_instance_identity()['document'] | |
region = iid_doc['region'] | |
instance_id = iid_doc['instanceId'] | |
ec2 = boto.ec2.connect_to_region(region) | |
instance = ec2.get_only_instances(instance_ids=[instance_id])[0] | |
env = instance.tags['elasticbeanstalk:environment-name'] | |
print(env) |
This file contains 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
packages: | |
yum: | |
newrelic-sysmond: [] | |
rpm: | |
newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm | |
commands: | |
100-setup-license-key: | |
command: nrsysmond-config --set license_key=YOUR_LICENSE_KEY | |
200-write-hostname: | |
command: echo hostname=`python /opt/elasticbeanstalk/hooks/appdeploy/pre/01-get-env-name.py` >> /etc/newrelic/nrsysmond.cfg | |
300-init-newrelic: | |
command: /etc/init.d/newrelic-sysmond start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment