Code Monkey home page Code Monkey logo

loggly-watch's Introduction

loggly-watch

This package provides a way to take facet searches run on your Loggly account and push the results to Amazon's CloudWatch service. The results can be used for alerting on certain types of events occuring in the logs on your servers.

Installation

Get started by installing the Python package 'hoover':

  sudo apt-get install python-setuptools
  sudo easy_install hoover

Download the package from Github by locally cloning the repository:

  cd ~/
  git clone [email protected]:loggly/loggly-watch.git

Configuring

Next, you'll need to set your AWS key and private keys. One way to do this is by editing your .profile and exporting them to the environment:

  vim ~/.profile
  export AWS_ACCESS_KEY_ID=your_aws_key_goes_here
  export AWS_SECRET_ACCESS_KEY_ID=your_aws_secret_key_goes_here

Or, you can just edit the line in the main.py file:

  cw = cloudwatch.connection('AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY_ID') 

You'll also need to set your Loggly credentials:

  hoover.authorize('ACCOUNT_NAME', 'USERNAME', 'PASSWORD')

and set your namespace for your site:

  namespace = 'Loggly'

Defining Searches

You'll need to configure a set of searches you want to run from Loggly. Change 'default' to the Loggly input you want to search.

The example below gets counts of events matching the wildcard search for a five minute window starting six minutes ago for the default input. Obviously this input needs to be receiving data from your web server to work.

  account_name = hoover.utils.get_input_by_name('default')
  num_results = account_name.facets(q='*', starttime='NOW-6MINUTES', endtime='NOW-1MINUTE', buckets=1)['data'].items()[0][1]

Running

Run the code to test it.

  python main.py

Now set it up as a cron job:

  crontab -e
  */5 * * * * python ~/loggly-watch/main.py

You should get custom data flowing into your CloudWatch account after about 5-10 minutes. Adjust your timeframes and cronjob as necessary, and add more searches for other use cases.

Results

Here's a sample output from a run over 12 hours or so, tracking total web log entries on the loggly.com website.

To graph the data on your own dashboard, use Micahel Babineau's CloudViz package.

loggly-watch's People

Watchers

cloud123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.