Skip to content

Instantly share code, notes, and snippets.

@JefStat
Last active September 25, 2020 21:15
Show Gist options
  • Save JefStat/98891d947a1bbadedcf25921b116e413 to your computer and use it in GitHub Desktop.
Save JefStat/98891d947a1bbadedcf25921b116e413 to your computer and use it in GitHub Desktop.
Elastic Beanstalk Sumo Logic Config
# This will automatically install the Sumo Logic collector on AWS Elastic
# Beanstalk instances. Add this to the .ebextensions folder in your app root
# To add or remove tracked files, simply add or remove source hashes to the
# sources array.
packages:
rpm:
SumoCollector: https://collectors.sumologic.com/rest/download/rpm/64
services:
sysvinit:
collector:
enabled: true
ensureRunning: true
files:
"/home/ec2-user/setup-sumo.sh":
mode: "000755"
owner: root
group: root
content: |
cat >/opt/SumoCollector/config/user.properties <<EOL
accessid=$SUMOLOGIC_ACCESS_ID
accesskey=$SUMOLOGIC_ACCESS_KEY
category=$SUMOLOGIC_SOURCE_CATEGORY
rpmAutoStart=false
syncSources=/etc/sumo-sources.json
ephemeral=true
syncSources=/opt/SumoCollector/config/sumo_sources.json
sources=/opt/SumoCollector/config/sumo_sources.json
EOL
"/opt/SumoCollector/config/sumo_sources.json":
mode: "000755"
owner: root
group: root
content: |
{
"api.version": "v1",
"sources": [
{
"sourceType": "LocalFile",
"pathExpression": "/var/log/eb-docker/containers/eb-current-app/*.log",
"multilineProcessingEnabled": true,
"useAutolineMatching": true,
"automaticDateParsing": true
}
]
}
"/opt/elasticbeanstalk/tasks/taillogs.d/sumo-logic.conf" :
mode: "000755"
owner: root
group: root
content: |
/opt/SumoCollector/logs/*
"/opt/elasticbeanstalk/tasks/bundlelogs.d/sumo-logic.conf" :
mode: "000755"
owner: root
group: root
content: |
/opt/SumoCollector/logs/*
"/opt/elasticbeanstalk/tasks/publishlogs.d/sumo-logic.conf" :
mode: "000755"
owner: root
group: root
content: |
/opt/SumoCollector/logs/*
container_commands:
setup_sumo:
command: /home/ec2-user/setup-sumo.sh
@JefStat
Copy link
Author

JefStat commented Mar 7, 2017

Ephemeral added
docker container logs added

@ShadySQL
Copy link

ShadySQL commented Apr 3, 2017

What environment variables did you pass in to your EBS application? I am not able to get this working on my account.

@phekno
Copy link

phekno commented Nov 15, 2017

It looks like Elastic Beanstalk sets the environment variables some time after it runs the .ebextensions configs, which means setup-sumo just puts empty strings in for the id/key and any Elastic Beanstalk application deploys or scaling events fail.

@dimamix
Copy link

dimamix commented Nov 23, 2017

One observations from our experience after launching this: Each item in the sources array must also include a name property. Without it, no source was detected or defined.

@rcollette
Copy link

Forked to add source names, order properties as executed according to AWS documentation, and restart the service since the user.properties file is not present before service start. Beanstalk environment variables work just fine.
https://gist.github.com/rcollette/95667454dc054d9d308e5b4d9a80f419

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