Coder Social home page Coder Social logo

marhan / micrometer-prometheus-grafana-talk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fitzoh/micrometer-prometheus-grafana-talk

0.0 1.0 0.0 158 KB

Supporting content for a talk on monitoring JVM applications with Micrometer, Prometheus, and Grafana.

Home Page: https://docs.google.com/presentation/d/14Z23SLsCwZFDXOOFAcCoDAXf8LCmWbv99b9qXiQtRr0/

Kotlin 40.91% Java 59.09%

micrometer-prometheus-grafana-talk's Introduction

Application monitoring with Micrometer, Prometheus, and Grafana

Companion code for the (hopefully somewhat useful) presentation you just sat through!

Feedback appreciated, @fitzoh on Twitter.

Links

Slides

Micrometer

Prometheus

Grafana

Logstash Logback Encoder

USE/RED methods

3 pillars of observability (take your pick)

Slide code snippets generated via Carbon

Demo

Instructions assume a *NIX machine, sorry windows people. Some steps block, use multiple terminals where necessary. Prometheus and Grafana require Docker.

Spring Boot Apps

The demo assumes two instances of the Spring Boot service are running. Start them like this:

  • ./gradlew bootRun
  • SPRING_PROFILES_ACTIVE=slow ./gradlew bootRun

They'll run on ports 8080 and 8081.

You can view the prometheus endpoints generated by the application/micrometer at (:8080/actuator/prometheus)[http://localhost:8080/actuator/prometheus] and :8081/actuator/prometheus.

You can also manually make requests to the following applicaton endpoints:

Prometheus

Start Prometheus via ./gradlew startPrometheus. You can view the UI at port 9090. The config file is prometheus.yml.

Grafana

Start Grafana via ./gradlew startGrafana. You can view the UI at port 3000 (log in with admin:grafana). State is persisted through a volume in the grafana directory.

Logging

The src/main/java/com/github/fitzoh/monitoring/logging directory contains a simple example to show the difference between default Spring Boot logging settings and structured JSON logging using the Logstash Logback Encoder.

On application startup (./gradlew bootrun), the default logger outputs something that looks like this:

output:

2019-02-23 10:01:03.118  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 0
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 1
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 2
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 3
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 4
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 5
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 6
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 7
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 8
2019-02-23 10:01:03.119  INFO 7777 --- [           main] c.g.f.l.SuperBoringPlainLogExample       : doing a thing 9

If you run it with the json logger enabled (./gradlew bootRun --args='--spring.profiles.active=json'):

output:

{"@timestamp":"2019-02-23T10:01:42.277-05:00","@version":"1","message":"doing a thing structured_value=0","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"0","marker_value":0,"structured_value":0}
{"@timestamp":"2019-02-23T10:01:42.289-05:00","@version":"1","message":"doing a thing structured_value=1","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"1","marker_value":1,"structured_value":1}
{"@timestamp":"2019-02-23T10:01:42.289-05:00","@version":"1","message":"doing a thing structured_value=2","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"2","marker_value":2,"structured_value":2}
{"@timestamp":"2019-02-23T10:01:42.290-05:00","@version":"1","message":"doing a thing structured_value=3","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"3","marker_value":3,"structured_value":3}
{"@timestamp":"2019-02-23T10:01:42.290-05:00","@version":"1","message":"doing a thing structured_value=4","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"4","marker_value":4,"structured_value":4}
{"@timestamp":"2019-02-23T10:01:42.290-05:00","@version":"1","message":"doing a thing structured_value=5","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"5","marker_value":5,"structured_value":5}
{"@timestamp":"2019-02-23T10:01:42.290-05:00","@version":"1","message":"doing a thing structured_value=6","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"6","marker_value":6,"structured_value":6}
{"@timestamp":"2019-02-23T10:01:42.290-05:00","@version":"1","message":"doing a thing structured_value=7","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"7","marker_value":7,"structured_value":7}
{"@timestamp":"2019-02-23T10:01:42.290-05:00","@version":"1","message":"doing a thing structured_value=8","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"8","marker_value":8,"structured_value":8}
{"@timestamp":"2019-02-23T10:01:42.292-05:00","@version":"1","message":"doing a thing structured_value=9","logger_name":"com.github.fitzoh.loggingexample.AwesomeJsonLogExample","thread_name":"main","level":"INFO","level_value":20000,"mdc_value":"9","marker_value":9,"structured_value":9}

cleaned up with jq:

{
  "@timestamp": "2019-02-23T10:01:42.277-05:00",
  "@version": "1",
  "message": "doing a thing structured_value=0",
  "logger_name": "com.github.fitzoh.loggingexample.AwesomeJsonLogExample",
  "thread_name": "main",
  "level": "INFO",
  "level_value": 20000,
  "mdc_value": "0",
  "marker_value": 0,
  "structured_value": 0
}

Note that you won't generally log the same values using MDC, Markers, and structured arguments. All three are included here for the sake of demonstrating available options.

micrometer-prometheus-grafana-talk's People

Contributors

cjudd avatar fitzoh 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.