Code Monkey home page Code Monkey logo

java-logging's Introduction

Centralized Application Logs with the Elastic Stack

This repository gives an overview of five different logging patterns:

  • Parse: Take the log files of your applications and extract the relevant pieces of information.
  • Send: Add a log appender to send out your events directly without persisting them to a log file.
  • Structure: Write your events in a structured file, which you can then centralize.
  • Containerize: Keep track of short lived containers and configure their logging correctly.
  • Orchestrate: Stay on top of your logs even when services are short lived and dynamically allocated on Kubernetes.

The slides for this talk are available on Speaker Deck.

Dependencies

  • JDK 8+ and Gradle to run the Java code.
  • Docker (and Docker Compose) to run all the required components of the Elastic Stack (Filebeat, Logstash, Elasticsearch, and Kibana) and the containerized Java application.

Usage

  • Bring up the Elastic Stack: $ docker-compose up
  • Run the Java application: $ gradle run
  • Remove the Elastic Stack (and its volumes): $ docker-compose down -v

Demo

  1. Take a look at the code โ€” which pattern are we building with log statements here?
  2. Run it with gradle run and see the output in the console.

Parse

  1. Copy a log line and start disecting it with the Grok Debugger in Kibana, for example with the pattern ^\[%{TIMESTAMP_ISO8601:timestamp}\]%{SPACE}%{LOGLEVEL:level}. The rest will be done with the logstash.conf.
  2. Try to find the log statements in Kibana's Discover view for the parse index.
  3. Show the last 15min and up to 3h into the future to see that the timestamp is wrong. Fix it by uncommenting the timezone field and restart Logstash with docker-compose restart logstash.
  4. Also show the pipeline in Kibana's monitoring view.
  5. Run the code again and see that the timezone is fine now. But we have 42 entries instead of 40 โ€” though 42 would generally be the perfect number.
  6. See the _grokparsefailure in the tag field. Enable the multiline rules in Filebeat and restart it with docker-compose restart filebeat_for_logstash .
  7. Show that this is working as expected now and drill down to the errors to see which emoji we are logging.
  8. Create a vertical bar chart visualization on the level field. Further break it down into session.

Send

  1. Run the sunshine case and show the data in the send index.
  2. Stop Logstash with docker-compose stop logstash.
  3. Run the application and restart Logstash after that again with docker-compose start logstash.
  4. Show the missing data for example by comparing it to the results in the parse index, which will be populated once Filebeat can reach Logstash again.

Structure

  1. Run the application and show the data in the structure index.
  2. Show the Logback configuration for JSON, since it is a little more complicated than the others.

java-logging's People

Contributors

xeraa avatar

Watchers

Selva Kumar Muthu Krishnan 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.