GithubHelp home page GithubHelp logo

chops's Introduction

chops

DevOps chatbot tool for posting log file entries into Slack channels.

This is a PHP CLI based daemon that can tail a log file, look for REGEX patterns (like "WARN" or "ERROR") and post them into a Slack Channel when they occur.

I find myself more and more interacting with my team and with customers and partners on Slack Channels, and this often includes DevOps. I needed a way that I could push log file entries into a channel so that WARN and ERROR messages could be easily discussed across a group.

The longer term vision for this project is for a more interactive chatbot that can perform some basic command and control tasks. This initial version is just a case of "tail a file, catch REGEX patterns and drop matches into a channel".

Dependencies

To install it, you'll need to satisfy the following dependencies:

PHP CLI is usually available on most common distributions. Installing this on a recent Fedora, for example, is very simple:

yum install php-cli

On Ubuntu or Debian, it would require something like this:

apt-get install php-cli

I've not yet come across a Linux distribution that does not have tail installed.

Installation

Once you have installed the dependencies, get the code:

git clone https://github.com/deanelwood/chops.git /usr/local/chops
cd /usr/local/chops

Create your Slack app and get a Web Hook URL

You will need a Web Hook URL to the Slack channel that you wish to post log messages into. I recommend that you start here:

Once you have created your app and Slack has given you a URL to use for the webhook you can configure CHOPS.

Configuration

You will need to edit some values in /usr/local/chops/chops.conf, at least these:

slackurl=
logfile=
warnpattern=
errorpattern=

An example configuration that monitors the file /var/log/myapp.log might look like this:

slackurl=https://hooks.slack.com/services/<uuid>/
logfile=/var/log/myapp.log
warnpattern=/WARN/
errorpattern=/ERR/

With this example configuration, any lines in /var/log/myapp.log that are spotted containing the text "ERR" will be sent immediately to your Slack channel. Any lines that contain the text "WARN" will be counted and if more than 3 are seen in a space of 5 minutes a message will be posted into the Slack channel. You can change these presets by altering the values 3 and 5 for warningsbeforealarm and warningswindow accordingly in the configuration file.

Launching

If you installed using the above path of /usr/local/ you can launch with php /user/local/chops.php &

When launched, CHOPS will post a message into your Slack channel like this:-

CHOPS launch message

Contributing

You can contribute to the project by forking and submitting a pull request. (If you are new to GitHub, you might start with a basic tutorial.)

All contributors retain the original copyright to their code, but by contributing to this project, grant a world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license to all users under the terms of the MIT License.

License

This project constitutes an original work.

You may use this project under the MIT License.

chops's People

Contributors

deanelwood avatar

chops's Issues

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.