Springboot App Metrices push to opentelementary with grafna and prometheus
- Anand Nerurkar
- Feb 16
- 1 min read
Updated: Feb 18

develop springboot app with spring initlaizer as per github link
build and install, run it

add application.yml
==
spring:
application:
name: springappotdemo
management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
promotheus is enabled

build and run it

let us create docker compose for promotheus and grafna as below
docker-compose.yml
====
version: '3'
services:
prometheus:
container_name: prometheus
image: prom/prometheus
restart: always
command:
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
grafana:
container_name: grafana
image: grafana/grafana
ports:
- "3000:3000"
let us create docker/promotheus folder at project level and create promotheus.yml file as below
promotheus.yml
===
global:
scrape_interval: 10s
evaluation_interval: 10s
scrape_configs:
- job_name: 'otel-collector'
static_configs:
- targets: ['host.docker.internal:8889']
pls issue command docker compose up to set up promotheus and grafna
docker compose up -d



So we have successfully integrated grafna and prmetheus.

To integrate Springboot App with OpenTelementary
====

add entry for open telemntry into pom xml
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-otlp</artifactId>
<scope>runtime</scope>
</dependency>
update application.yml for opentelementry as below
otlp:
metrics:
export:
step: 10s
update docker compose.yml for open telementary collector
otel-collector:
image: otel/opentelemetry-collector-contrib:0.82.0
restart: always
command:
- --config=/etc/otelcol-contrib/otel-collector.yml
volumes:
- ./docker/collector/otel-collector.yml:/etc/otelcol-contrib/otel-collector.yml
ports:
- "1888:1888" # pprof extension
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
- "55679:55679" # zpages extension
Comments