Spring Boot logging with Loki, Promtail, and Grafana (Loki stack)

This page summarizes the projects mentioned and recommended in the original post on dev.to

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. spring-boot-debug-app

    Spring Boot application for debugging purpose.

    This is a GitHub link to my demo app. It’s simple Spring Boot web app used to debugging various stuff. There are many ways to configure JSON logging in Spring Boot. I decided to use Logback because it is easy to configure and one of the most widely used logging library in the Java Community. To enable JSON logging we need to add below dependencies.

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. helm-charts

    Grafana Labs in its Helm repository provides chart that can install Loki stack also with other complementary tools like Logstash or Prometheus.

  4. Logback

    The reliable, generic, fast and flexible logging framework for Java.

    This is a GitHub link to my demo app. It’s simple Spring Boot web app used to debugging various stuff. There are many ways to configure JSON logging in Spring Boot. I decided to use Logback because it is easy to configure and one of the most widely used logging library in the Java Community. To enable JSON logging we need to add below dependencies.

  5. grafana-loki-stack-helmfile

    Grafana Loki stack with predefined dashboard - helmfile installation

    Firstly, clone my repo with Lok stack helmfile, and check how little configuration is needed to install all stuff. This is because the Loki stack installation comes with reasonably safe defaults whenever possible, so we have only to overwrite some crucial values. To install it we need to exec single command.

  6. jmespath.py

    JMESPath is a query language for JSON.

    Thanks to custom variables that use labels, we can create various filters for the dashboard. You can look up my configuration of variables and extend it with an analogy way for your own needs. At the top, I marked the filter with detected pods in selected namespace. In the lower part, you can see a preview of all labels that are associated with a single log line. Most labels are meta information that Promtail adds during scraping targets. This part of the Promtail configuration provides it. In this section, I also marked a few labels that not comes out-of-the box e.g. leavel , class , thread . We added these labels using the Promtail json stage. You need to know that Promtail processes scraped logs in a pipeline. A pipeline is comprised of a set of stages. json stage is a parsing stage that reads the log line as JSON and accepts JMESPath expressions to extract data.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Loki with grafana.

    1 project | /r/kubernetes | 2 Jul 2023
  • Grafana for K8S - configure dashboard access permissions

    1 project | /r/codehunter | 30 May 2023
  • Promtail tenant doesn't apply

    1 project | /r/grafana | 13 Dec 2022
  • Grafana Helm Chart - LDAP not working

    1 project | /r/grafana | 11 Oct 2022
  • Promtail Access to Loki Server Push Only?

    1 project | /r/grafana | 21 Aug 2021

Did you know that Java is
the 8th most popular programming language
based on number of references?