amazon-web-servicesamazon-ec2logentries

How to auto create new hosts in Logentries for AWS EC2 autoscaling group


What's the best way to send logs from Auto scaling groups (of EC2) to Logentries.

I previously used the EC2 platform to create EC2 log monitoring for all of my EC2 instances created by an Autoscaling group. However according to Autoscaling rules, new instance will spin up if a current one is destroyed.

Now how do I create an automation for Logentries to create a new hosts and starting getting logs. I've read this https://logentries.com/doc/linux-agent-with-chef/#updating-le-agent I'm stuck at the override['le']['pull-server-side-config'] = false since I don't know anything about Chef (I just took the training from their site)


Solution

  • For an Autoscaling group, you need to get this baked into an AMI, or scripted to run on startup. You can get an EC2 instance to run commands on startup, after you've figured out which script to run.

    The Logentries Linux Agent installation docs has setup instructions for an Amazon AMI (under Installation > Select your distro below > Amazon AMI).

    Run the following commands one by one in your terminal:

    You will need to provide your Logentries credentials to link the agent to your account.

    sudo -s
    tee /etc/yum.repos.d/logentries.repo <<EOF
    [logentries]
    name=Logentries repo
    enabled=1
    metadata_expire=1d
    baseurl=http://rep.logentries.com/amazon\$releasever/\$basearch
    gpgkey=http://rep.logentries.com/RPM-GPG-KEY-logentries
    EOF
    yum update
    yum install logentries
    le register
    yum install logentries-daemon
    

    I recommend trying that script once and seeing if it works properly for you, then you could include it in the user data for your Autoscaling launch configuration.