Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up Loggly on Elastic Beanstalk?

I'd like to set up Loggly to run on AWS Elastic Beanstalk, but can't find any information on how to do this. Is there any guide anywhere, or some general guidance on how to start?

like image 729
Ken Liu Avatar asked Jun 29 '12 01:06

Ken Liu


People also ask

Where does Elastic Beanstalk store logs files?

Elastic Beanstalk creates a bucket named elasticbeanstalk- region - account-id for each AWS Region in which you create environments. Within this bucket, logs are stored under the path resources/environments/logs/ logtype / environment-id / instance-id .

What is Load Balancer in Elastic Beanstalk?

When you enable load balancing, AWS Elastic Beanstalk creates an Elastic Load Balancing load balancer dedicated to your environment. Elastic Beanstalk fully manages this load balancer, taking care of security settings and of terminating the load balancer when you terminate your environment.


2 Answers

This is how I do it, for papertrailapp.com (which I prefer instead of loggly). In your /ebextensions folder (see more info) you create logs.config, where specify:

container_commands:
  01-set-correct-hostname:
    command: hostname www.example.com
  02-forward-rsyslog-to-papertrail:
    # https://papertrailapp.com/systems/setup
    command: echo "*.* @logs.papertrailapp.com:55555" >> /etc/rsyslog.conf
  03-enable-remote-logging:
    command: echo -e "\$ModLoad imudp\n\$UDPServerRun 514\n\$ModLoad imtcp\n\$InputTCPServerRun 514\n\$EscapeControlCharactersOnReceive off" >> /etc/rsyslog.conf
  04-restart-syslog:
    command: service rsyslog restart

55555 should be replaced with the UDP port number provided by papertrailapp.com. Every time after new instance bootstrap this config will be applied. Then, in your log4j.properties:

log4j.rootLogger=WARN, SYSLOG
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.facility=local1
log4j.appender.SYSLOG.header=true
log4j.appender.SYSLOG.syslogHost=localhost
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.ConversionPattern=[%p] %t %c: %m%n

I'm not sure whether it's an optimal solution. Read more about this mechanism in jcabi-beanstalk-maven-plugin

like image 119
yegor256 Avatar answered Oct 14 '22 13:10

yegor256


You can also use the installation script from loggly itself. The setup below follows the instructions for the legacy setup on https://www.loggly.com/docs/configure-syslog-script/ with minor changes (no confirmation prompts, sudo command replaced since no tty is available)

(edit: updated link, seems to be an outdated solution now in loggly docs)

Place the following script in .ebextensions/loggly.config

Replace TOKEN and ACCOUNT with your own.

#
# Install loggly.com on AWS Elastic Beanstalk
# Tested with node.js environment
# Save this file as .ebextensions/loggly.config
# Deploy per normal scripts or aws.push. To help debug the push, ssh & tail /var/log/cfn-init.log
# See Also /var/log/eb-tools.log
#

commands:
  01_loggly_dl:
    command: wget -q -O /tmp/loggly.py https://www.loggly.com/install/configure-syslog.py
  02_loggly_config:
    command: su --session-command="python /tmp/loggly.py setup --auth TOKEN --account ACCOUNT --yes"
like image 21
Andreas Avatar answered Oct 14 '22 13:10

Andreas