Git Product home page Git Product logo

catl's Introduction

catl

Kibana is an excellent tool for visualising and performing analysis on your log data but I've found that the Discover pane isn't that effective when you are trying to pull contextual information about a particular event in a log (what happened before and after a particular error?) or in a number of other situations where commandline utilities like grep have traditionally been useful.

catl is my attempt to address this problem. It's a simple program that executes a search query against an elasticsearch cluster and returns the message field in timestamp order on stdout. This allows you to use utilities like grep, awk and sed to parse your logs for information as if it was a file on your local disk.

Build

$ go build

Usage

$ catl -h
usage: catl [<flags>] <query>

Writes a logstash elasticsearch query to stdout as if it were a logfile

Flags:
  -h, --help                     Show context-sensitive help (also try --help-long and --help-man).
  -i, --index="logstash-*"       Index pattern.
  -u, --url="http://localhost:9200"
                                 Logstash server URL.
  -m, --message-field="message"  Field to be returned
  -s, --sort-field="@timestamp"  Field to sort the results by

Args:
  <query>  Elasticseach query string.

You can set any of the flags with environment variables in the form CATL_$FLAG:

export CATL_INDEX=logstash-2018.07.02
export CATL_MESSAGE_FIELD=logmessage

Examples

Returns ERROR level logs along with the preceding message:

$ catl 'meta.service: "foobar" AND meta.environment: "live" AND type: "java_logback"' | grep 'ERROR' -B 1
2018-07-03 00:00:00,522 [http-nio-8080-exec-7] DEBUG c.b.b.f.c.SillyClass - Doing something...
2018-07-03 00:00:00,522 [http-nio-8080-exec-4] ERROR  c.b.b.f.SillyErrorClass - Something foolish happened

Save the output to a file:

$ catl 'meta.service: "foobar" AND meta.environment: "live" AND type: "java_logback" AND loglevel: "ERROR"' > errors.log

catl's People

Contributors

ribbybibby avatar

Stargazers

Andrey avatar

Watchers

James Cloos avatar  avatar  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.