Skip to content

Commit

Permalink
feat : grafana LGTM sample (#1189)
Browse files Browse the repository at this point in the history
* feat : grafana LGTM sample

* adds workflow

* Update boot-grafana-lgtm/ReadMe.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat : fetch grafana port

* Update boot-grafana-lgtm/ReadMe.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
rajadilipkolli and coderabbitai[bot] authored Apr 12, 2024
1 parent 43a3804 commit 191b6e3
Show file tree
Hide file tree
Showing 18 changed files with 854 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/boot-choas-monkey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/[email protected]
with:
java-version: 21
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/boot-grafana-lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: boot-grafana-lgtm

on:
push:
paths:
- "boot-grafana-lgtm/**"
branches: [main]
pull_request:
paths:
- "boot-grafana-lgtm/**"
types:
- opened
- synchronize
- reopened

jobs:
build:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: boot-grafana-lgtm
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 21
uses: actions/[email protected]
with:
java-version: 21
distribution: "temurin"
cache: "maven"

- name: Build and analyze
run: ./mvnw clean package
37 changes: 37 additions & 0 deletions boot-grafana-lgtm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Misc ###
*.log
.DS_Store
Binary file added boot-grafana-lgtm/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions boot-grafana-lgtm/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
23 changes: 23 additions & 0 deletions boot-grafana-lgtm/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# boot-grafana-lgtm

LGTM stands for Loki, Grafana, Tempo and Mimir. It’s Grafana’s tool stack that enables logs, metrics, and traces to be collected and visualized within a single stack of tools that works in harmony

## Grafana

Grafana is the visualization tool for the whole stack. It allows you to visualize metrics, logs, traces, and many more with its plentiful dashboards and integrations.

## Loki

Loki is the log aggregator of the LGTM stack. Logs are pushed to Loki, indexed based on given labels and stored within a defined storage. This can be the filesystem, a database (Cassandra, BigTable, DynamoDB), or an object storage. The logs can then be queried from Grafana or through Loki’s API using LogQL, a query language similar to Prometheus’ PromQL.

## Mimir

Mimir is the long-term metric storage of the LGTM stack. It receives Prometheus metrics through its Prometheus remote write API and stores them on object storage. Metrics can be queried through Grafana or Mimir’s API using PromQL. Mimir is Prometheus-compatible, meaning that any application using Prometheus APIs can use Mimir without any change in the codebase.

## Tempo

Tempo is the tracing backend of the LGTM stack. It collects traces in Jaeger, Zipkin, and OpenTelemetry formats. You can then query the traces from Grafana and visualize the path of every request within a distributed system.

## Flow

![img.png](img.png)
17 changes: 17 additions & 0 deletions boot-grafana-lgtm/config/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
global:
scrape_interval: 2s
evaluation_interval: 2s

scrape_configs:
- job_name: 'boot-grafana-lgtm'
scrape_interval: 2s
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['host.docker.internal:8080']
labels:
application: 'boot-grafana-lgtm'
- job_name: 'prometheus'
static_configs:
- targets: ['host.docker.internal:9090']
labels:
application: 'prometheus'
29 changes: 29 additions & 0 deletions boot-grafana-lgtm/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.8'
services:

grafanalgtm:
image: grafana/otel-lgtm:0.5.0
extra_hosts: ['host.docker.internal:host-gateway']
container_name: grafanalgtm
environment:
- OTEL_METRIC_EXPORT_INTERVAL=500
ports:
- "3000:3000"
- "4317:4317"
- "4318:4318"

prometheus:
image: prom/prometheus:v2.51.1
extra_hosts: ['host.docker.internal:host-gateway']
container_name: prometheus
command:
- --enable-feature=exemplar-storage
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ../config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
ports:
- "9090:9090"
healthcheck:
interval: 5s
retries: 10
test: wget --no-verbose --tries=1 --spider http://localhost:9090/status || exit 1
Binary file added boot-grafana-lgtm/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 191b6e3

Please sign in to comment.