Coder Social home page Coder Social logo

sumoshell's Introduction

sumoshell

Join the chat at https://gitter.im/SumoLogic/sumoshell

Sumoshell is collection of utilities to improve analyzing log files written in Go. grep can't tell that some log lines span multiple individual lines. Parsing out fields is cumbersome. Aggregating is basically impossible, and there is no good way to view the results. In Sumoshell, each individual command acts as a phase in a pipeline to get the answer you want. Sumoshell brings a lot of the functionality of Sumo Logic to the command line.

Commands should start with sumo search [filter] which will transform logs into the json format sumoshell uses. Commands should end with render render-basic or graph which render the output to the terminal. Each operator is a stand-alone binary allowing them to be easily composed.

Installation

OSX and Linux binaries are provided for sumoshell. Simply extract the archive and place the binaries on your path.

If you run a different OS or would prefer to install from source, it's easy to build from source. Given a working go installation, run:

go get github.com/SumoLogic/sumoshell
cd $GOPATH/src/github.com/SumoLogic/sumoshell # Will warn about `no buildable go source`
go get ./...
go install ./...

Usage

Like SumoLogic, sumoshell enables you pass log data through a series of transformations to get your final result. Pipelines start with a source (tail, cat, etc.) followed by the sumo operator. An example pipeline might be:

tail -f logfile | sumo search "ERROR" | sumo parse "thread=*]" | sumo count thread | render-basic

This would produce a count of log messages matching ERROR by thead. In the basic renderer, the output would look like:

_Id   _count   thread   
0     4        C        
1     4        A        
2     1        B      

The sumo search operator

sumo search takes an optional filter parameter to allow for basic searching. The sumo operator performs 3 steps:

  1. Break a text file into logical log messages. This merges things like stack traces into a single message for easy searching.
  2. Allow basic searching.
  3. Transforms the log message into the sumoshell internal json format.

Displaying results

After using the sumo operator, the output will be in JSON. To re-render the output in a human-readable form, | the results of your query into one of the three render operators.

  1. render-basic: Capable of rendering aggregate and non-aggregate data. Mimics curses style CLIs by calculating the terminal height and printing new lines to the end to keep your text aligned. Add nowraw to drop the raw data when an aggregate isn't present.
  2. render: Curses based renderer for rendering tabular data.
  3. graph: Curses based renderer for rendering tabular data as a bar chart.

Parsing Data

sumoshell supports a basic parse operator similar to the parse operator in SumoLogic. Queries take the form:

... | sumo parse "[pattern=*] pattern2:'*' morePatterns=(*)" as pattern, pattern2, more | ...

Filtering Data

sumoshell supports a filter operator similar to the where operator in SumoLogic. Queries take the form:

... | sumo parse "[host=*]" as host | sumo filter host = server1 

This will drop any log lines that don't have server1 as the host.

Aggregating Data

sumoshell currently supports 3 aggregate operators:

  1. count Example queries:
... | sumo count           # number of rows
... | sumo count key       # number of rows per key
... | sumo count key value # number of rows per the cartesian product of (key, value)

  1. sum Example queries:
... | sumo sum k      # sum of all k's
... | sumo sum v by k # sum of all v's by k

  1. average Example queries:
... | sumo average k      # average of all k's
... | sumo average v by k # average of all v's by k

sumoshell's People

Contributors

cddude229 avatar matthewcallis avatar rcoh avatar

Watchers

 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.