-
-
Save rcollette/95667454dc054d9d308e5b4d9a80f419 to your computer and use it in GitHub Desktop.
Elastic Beanstalk Sumo Logic Config via Gitlab Environment Variable
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
# 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 | |
files: | |
"/home/ec2-user/setup-sumo.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
# beanstalk environment variables are available here because this is a shell script. | |
# To not have the variable replaced by Gitlab during build, use double dollar signs. | |
content: | | |
cat >/opt/SumoCollector/config/user.properties <<EOL | |
name=$TEAM_SHORT_NAME-$SUMOLOGIC_APP_NAME-$${DEPLOYMENT_ENVIRONMENT}-$$(hostname) | |
accessid=$SUMOLOGIC_ACCESS_ID | |
accesskey=$SUMOLOGIC_ACCESS_KEY | |
category=$TEAM_SHORT_NAME/$${DEPLOYMENT_ENVIRONMENT}/$SUMOLOGIC_APP_NAME | |
rpmAutoStart=false | |
ephemeral=true | |
clobber=false | |
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 | |
#beanstalk environment variables are not available here. | |
content: | | |
{ | |
"api.version": "v1", | |
"sources": [ | |
{ | |
"name": "docker", | |
"sourceType": "LocalFile", | |
"multilineProcessingEnabled": true, | |
"useAutolineMatching": true, | |
"pathExpression": "/var/lib/docker/containers/*/*.log", | |
"automaticDateParsing": true | |
}, | |
{ | |
"name": "nginx", | |
"sourceType": "LocalFile", | |
"automaticDateParsing": true, | |
"multilineProcessingEnabled": "false", | |
"useAutolineMatching": true, | |
"pathExpression": "/var/log/nginx/*.log" | |
} | |
] | |
} | |
"/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: | |
01_setup_sumo: | |
command: /home/ec2-user/setup-sumo.sh | |
# The service restart is required because the rpm installation seems to start the service before commands are run. | |
02_restart_service: | |
command: /sbin/service collector restart | |
services: | |
sysvinit: | |
collector: | |
enabled: true | |
ensureRunning: true | |
#Note the following commands usage does not actually restart the service after setup-sumo.sh has run. | |
#commands: | |
#- 01_setup_sumo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist provide an example of configuring a Sumo Logic collector for an AWS Elastic Beanstalk, via a Gitlab variable. We define this variable at a gitlab group level.
The variable is copied to a file in gitlab-ci.yml like:
The order of the properties (packages, files, container_commands, services) in this file reflect the documented order of execution from
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-services
Changing the order of these properties will not change the order of execution.