Overview
The BE Monorepo uses the Grafana LGTM (Loki, Grafana, Tempo, Mimir/Prometheus) stack for observability, packaged in thegrafana/otel-lgtm Docker image.
Docker Compose Configuration
The LGTM stack is defined indocker/docker-compose.yml:
docker/docker-compose.yml:25
Starting the Stack
1. Start Docker Compose
2. Verify Services
Check that all containers are running:3. Check Logs
Accessing Services
Grafana UI
- URL:
http://localhost:3111 - Default username:
admin - Default password:
admin
OTLP Endpoints
The application sends telemetry data to these endpoints:- HTTP:
http://localhost:4318 - gRPC:
http://localhost:4317
.env:
Data Sources
The LGTM image comes with pre-configured data sources:1. Prometheus (Metrics)
- Name: Prometheus
- Type: Prometheus
- URL:
http://localhost:9090
2. Tempo (Traces)
- Name: Tempo
- Type: Tempo
- URL:
http://localhost:3200
- Trace ID
- Service name
- Operation name
- Tags
3. Loki (Logs)
- Name: Loki
- Type: Loki
- URL:
http://localhost:3100
4. Pyroscope (Profiles)
- Name: Pyroscope
- Type: Pyroscope
- URL:
http://localhost:4040
Using Grafana
Explore View
The Explore view is ideal for ad-hoc querying:- Click Explore in the left sidebar
- Select a data source (Prometheus, Tempo, Loki)
- Enter your query
- Click Run query
Querying Logs
Basic Log Query
Filter by Severity
Search for Text
Filter by Request ID
Querying Traces
Search by Service
- Go to Explore → Tempo
- Select Search tab
- Filter by:
- Service Name:
be-monorepo - Span Name:
GET /api/users - Status:
error
- Service Name:
View Trace Details
Click on a trace to see:- Full request timeline
- Span hierarchy
- Span attributes
- Logs correlated with the trace
- Related traces
Querying Metrics
HTTP Request Rate
Response Time Percentiles
Error Rate
Creating Dashboards
1. Create New Dashboard
- Click + → Create Dashboard
- Click Add visualization
- Select a data source
- Configure your query
- Customize visualization (graph, table, gauge, etc.)
- Click Save
2. Example HTTP Dashboard
Request Rate Panel
Response Time Panel
Status Code Distribution Panel
Active Requests Panel
3. Save Dashboard
- Click Save dashboard icon (💾)
- Enter a name: “HTTP Metrics”
- Click Save
Correlating Telemetry Data
One of the most powerful features is correlating logs, traces, and metrics.Logs → Traces
- Query logs in Explore
- Find a log entry with a trace ID
- Click Tempo link next to the trace ID
- View the full trace
Traces → Logs
- Open a trace in Tempo
- Click on a span
- Click Logs for this span
- View correlated logs
Metrics → Traces
- Find a metric spike in a dashboard
- Click on the spike
- Select View traces
- Drill down into individual requests
Data Persistence
Data is persisted in Docker volumes:docker/docker-compose.yml:32
Backup Data
Clear Data
Alerting
Grafana supports alerting based on metrics and logs.Creating an Alert
- Go to Alerting → Alert rules
- Click New alert rule
- Define the query:
- Set evaluation interval:
1m - Add notification channel (email, Slack, etc.)
- Save
Alert Example: High Error Rate
Condition: Error rate > 5% for 5 minutesTroubleshooting
Application Not Sending Data
-
Check OTLP endpoint configuration:
-
Verify network connectivity:
-
Check application logs:
No Data in Grafana
- Verify data sources are configured
- Check time range (top right corner)
- Query Prometheus directly:
Container Issues
-
Restart the container:
-
Check container logs:
-
Verify port availability:
Performance Tuning
Retention Policies
Configure how long data is retained: Prometheus (metrics):Resource Limits
Limit container resources:Advanced Features
Service Graph
Visualize service dependencies:- Go to Explore → Tempo
- Select Service Graph tab
- View service topology
Trace to Metrics
Generate metrics from traces:- Go to Explore → Tempo
- Run a trace query
- Click Metrics tab
- View auto-generated metrics
Exemplars
Link metrics to traces:- Query a metric in Prometheus
- Click on a data point
- View exemplar traces
Resources
- Grafana Documentation
- Prometheus Query Language
- LogQL Documentation
- Tempo Documentation
- OpenTelemetry Specification
Next Steps
Logging
Learn about structured logging
Tracing
Implement custom traces
Metrics
Create custom metrics
Overview
Back to observability overview
