rust/capture-logs/README.md
A service that receives OpenTelemetry Protocol (OTLP) logs via HTTP and processes them based on team authentication.
/v1/logs and /i/v1/logs endpointsThe service is configured using environment variables:
| Variable | Default | Description |
|---|---|---|
| HOST | 0.0.0.0 | Host to bind the HTTP server |
| PORT | 8000 | Port for the HTTP server |
| JWT_SECRET | posthog_default_jwt_secret | Secret key for JWT validation |
Clients must authenticate by sending a valid token either:
Authorization: Bearer your-project-api-key
POST /v1/logs?token=your-project-token
The token is your PostHog project token.
cargo run --bin capture_logs
docker build -t posthog/capture-logs .
docker run -p 8000:8000 posthog/capture-logs
You can configure any OpenTelemetry-compatible client to send logs to this service. The service accepts:
Standard OTLP ExportLogsServiceRequest as JSON:
curl -X POST http://localhost:8000/v1/logs \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"resourceLogs":[{"resource":{"attributes":[]},"scopeLogs":[{"logRecords":[{"body":{"stringValue":"Hello World"}}]}]}]}'
Multiple ExportLogsServiceRequest objects, one per line:
curl -X POST http://localhost:8000/v1/logs \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d $'{"resourceLogs":[{"resource":{},"scopeLogs":[{"logRecords":[{"body":{"stringValue":"Log 1"}}]}]}]}\n{"resourceLogs":[{"resource":{},"scopeLogs":[{"logRecords":[{"body":{"stringValue":"Log 2"}}]}]}]}'
Standard OTLP protobuf encoding is also supported.
Requirements:
http://your-service-host:8000/v1/logsPOST /v1/logs - Accept OTLP logs (JSON, JSONL, or Protobuf)POST /i/v1/logs - Alternative endpoint for OTLP logsOPTIONS /v1/logs - CORS preflight supportOPTIONS /i/v1/logs - CORS preflight support/ - Basic information page/_readiness - Readiness probe for Kubernetes/_liveness - Liveness probe for Kubernetes/metrics - Prometheus metricscargo test
cargo build --release