tools/dev/kafka/README.md
This directory contains the development environment for testing Loki with Kafka integration. The setup provides supporting services (Kafka, Grafana, and a log generator) via docker-compose, while Loki itself needs to be run manually from source code for development purposes.
Start the supporting services (Kafka, Grafana, Log Generator):
docker-compose up -d
Run Loki manually with Kafka configuration:
# From the root of the Loki repository
go run ./cmd/loki/main.go --config.file=tools/dev/kafka/loki-local-config.debug.yaml --log.level=debug -target=all
Note: Loki is not included in docker-compose as it's intended to be run directly from source code for development.
localhost:9092loki is used for log ingestiondocker-compose.yaml: Service definitions and configurationloki-local-config.debug.yaml: Loki configuration with Kafka enabled
/tmp/lokiCreate .vscode/launch.json in the root directory:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Loki (Kafka)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/loki/main.go",
"args": [
"--config.file=../../tools/dev/kafka/loki-local-config.debug.yaml",
"--log.level=debug",
"-target=all"
],
"buildFlags": "-mod vendor"
}
]
}
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f kafka
docker-compose logs -f grafana
# Stop and remove containers
docker-compose down
# Remove local Loki data
rm -rf /tmp/loki
# Start fresh
docker-compose up -d
Check Kafka UI (http://localhost:8080) for:
Check Grafana (http://localhost:3000):
docker-compose ps)docker-compose logs broker)