How bh-gaur/lgtm works
Purpose and Entry Points
This repository demonstrates an instrumented two-service workload backed by PostgreSQL and a self-hosted Grafana LGTM observability stack. The Node.js service is the public gateway/UI and primary request entry point; the Python service performs downstream analytics and database work. Local orchestration begins with docker-compose.yml; Kubernetes deployment begins with helm/lgtm-stack/Chart.yaml.
Application Boundary: Node Gateway
The Node application serves the control UI, API routes, OpenAPI documentation, and Prometheus-compatible metrics on port 8081. It initiates downstream HTTP calls to Python and propagates W3C trace context. Instrumentation is separated so ENABLE_OBSERVABILITY can select active OpenTelemetry versus no-op behavior.
• apps/node-app/app.js
• apps/node-app/instrumentation.js
• apps/node-app/Dockerfile
Application Boundary: Python Analytics Service
The Flask service receives gateway requests on port 5000, handles analytics operations, and connects to PostgreSQL for query/insert work. It participates in the same distributed traces and exports telemetry when observability is enabled.
• apps/python-app/app.py
• apps/python-app/requirements.txt
• apps/python-app/Dockerfile
Business Request Flow
Client traffic reaches Node first. Node handles direct operations or calls the Python service through PYTHON_SERVICE_URL; Python performs SQL operations against PostgreSQL. Error-injection and compute routes create representative success, latency, and failure telemetry. Compose defines the local service network and infrastructure relationships.
• apps/node-app/app.js
• apps/python-app/app.py
• docker-compose.yml
Telemetry Collection and Signal Processing
Both applications export OTLP traces, metrics, and logs to Grafana Alloy, normally via OTLP HTTP. Alloy is the central boundary between application instrumentation and telemetry backends: it receives signals, derives RED/span metrics and exemplars, then routes traces, logs, and metrics to their respective stores.
• alloy/config.alloy
• helm/lgtm-stack/templates/alloy.yaml
• test-telemetry/send_telemetry.py
LGTM Storage and Visualization
Tempo stores traces, Loki stores logs, and Mimir stores metrics; Grafana queries all three through provisioned datasources. This enables trace/log correlation and metric exemplars linking measurements to Tempo trace IDs. Their runtime configuration is standalone for Compose and rendered through Helm for Kubernetes.
• tempo/tempo-config.yaml
• loki/loki-config.yaml
• mimir/mimir-config.yaml
• grafana/provisioning/datasources/datasources.yaml
Deployment Models and Infrastructure
Docker Compose is the local full-stack runtime, including PostgreSQL, apps, Alloy, and LGTM services. The Helm chart packages the same architecture as Kubernetes resources, with templates for each app and telemetry backend plus configurable persistence/storage class. PostgreSQL is an external state boundary used by Python; Loki, Mimir, and Tempo are stateful observability boundaries.
• docker-compose.yml
• helm/lgtm-stack/values.yaml
• helm/lgtm-stack/templates/node-app.yaml
• helm/lgtm-stack/templates/python-app.yaml
Main entry points: app.js Node gateway · docker-compose.yml Docker Compose · Chart.yaml LGTM Helm chart · config.alloy Alloy signal processing
Components 17
Application services
- Node gateway · Public UI, API, OpenAPI, and metrics endpoint on port 8081.
apps/node-app/app.js - Node instrumentation · Selects active or no-op telemetry using ENABLE_OBSERVABILITY.
apps/node-app/instrumentation.js - Python analytics · Analytics and database operations on port 5000.
apps/python-app/app.py
Telemetry pipeline
- Alloy OTLP ingest · Receives application traces, metrics, and logs via OTLP HTTP.
alloy/config.alloy - Alloy signal processing · Derives span metrics, RED metrics, and exemplars before export.
alloy/config.alloy
LGTM platform
Deployment models
- Docker Compose · Runs the local applications, database, Alloy, and LGTM stack.
docker-compose.yml - LGTM Helm chart · Packages the stack with configurable persistence and storage.
helm/lgtm-stack/Chart.yaml - Helm values · Configures chart services and persistence.
helm/lgtm-stack/values.yaml - Node workload
helm/lgtm-stack/templates/node-app.yaml - Python workload
helm/lgtm-stack/templates/python-app.yaml - Alloy workload
helm/lgtm-stack/templates/alloy.yaml
Other components
- Client
- PostgreSQL · External state boundary for Python query and insert work.
docker-compose.yml
Connections 21
- Client → Node gateway: HTTP requests
- Node gateway → Python analytics: PYTHON_SERVICE_URL · Propagates W3C trace context.
- Python analytics → PostgreSQL: SQL queries/inserts
- Node instrumentation → Node gateway: instruments
- Node gateway → Alloy OTLP ingest: OTLP signals
- Python analytics → Alloy OTLP ingest: OTLP signals
- Alloy OTLP ingest → Alloy signal processing: signals
- Alloy signal processing → Tempo: traces
- Alloy signal processing → Loki: logs
- Alloy signal processing → Mimir: metrics and exemplars
- Grafana → Tempo: query traces
- Grafana → Loki: query logs
- Grafana → Mimir: query metrics
- Docker Compose → Node gateway: runs locally
- Docker Compose → Python analytics: runs locally
- Docker Compose → PostgreSQL: runs locally
- Docker Compose → Alloy OTLP ingest: runs locally
- LGTM Helm chart → Helm values: configured by
- LGTM Helm chart → Node workload: renders
- LGTM Helm chart → Python workload: renders
- LGTM Helm chart → Alloy workload: renders