Skip to content

Commit cfc2fc8

Browse files
committed
feat: add OpenTelemetry Collector configuration
Add example OTel Collector config that scrapes DBLab's Prometheus endpoint and exports to OTLP-compatible backends. Update documentation with integration instructions.
1 parent 435e4dc commit cfc2fc8

2 files changed

Lines changed: 170 additions & 0 deletions

File tree

PROMETHEUS.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,58 @@ dblab_clone_cpu_usage_percent{clone_id="my-clone"}
166166
summary: "DBLab has many clones"
167167
description: "DBLab has {{ $value }} clones running"
168168
```
169+
170+
## OpenTelemetry Integration
171+
172+
DBLab metrics can be exported to OpenTelemetry-compatible backends using the OpenTelemetry Collector. This allows you to send metrics to Grafana Cloud, Datadog, New Relic, and other observability platforms.
173+
174+
### Quick Start
175+
176+
1. Install the OpenTelemetry Collector:
177+
```bash
178+
# Using Docker
179+
docker pull otel/opentelemetry-collector-contrib:latest
180+
```
181+
182+
2. Copy the example configuration:
183+
```bash
184+
cp engine/configs/otel-collector.example.yml otel-collector.yml
185+
```
186+
187+
3. Edit `otel-collector.yml` to configure your backend:
188+
```yaml
189+
exporters:
190+
otlp:
191+
endpoint: "your-otlp-endpoint:4317"
192+
headers:
193+
Authorization: "Bearer <your-token>"
194+
```
195+
196+
4. Run the collector:
197+
```bash
198+
docker run -v $(pwd)/otel-collector.yml:/etc/otelcol/config.yaml \
199+
-p 4317:4317 -p 8889:8889 \
200+
otel/opentelemetry-collector-contrib:latest
201+
```
202+
203+
### Architecture
204+
205+
```
206+
┌─────────────┐ scrape ┌──────────────────┐ OTLP ┌─────────────┐
207+
│ DBLab │ ──────────────► │ OTel Collector │ ──────────────► │ Backend │
208+
│ /metrics │ :2345 │ │ :4317 │ (Grafana, │
209+
└─────────────┘ └──────────────────┘ │ Datadog) │
210+
└─────────────┘
211+
```
212+
213+
### Supported Backends
214+
215+
The OTel Collector can export to:
216+
- **Grafana Cloud** - Use OTLP exporter with Grafana Cloud endpoint
217+
- **Datadog** - Use the datadog exporter
218+
- **New Relic** - Use OTLP exporter with New Relic endpoint
219+
- **Prometheus Remote Write** - Use prometheusremotewrite exporter
220+
- **AWS CloudWatch** - Use awsemf exporter
221+
- **Any OTLP-compatible backend**
222+
223+
See `engine/configs/otel-collector.example.yml` for a complete configuration example.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# OpenTelemetry Collector Configuration for Database Lab Engine
2+
#
3+
# This configuration scrapes Prometheus metrics from DBLab's /metrics endpoint
4+
# and exports them via OTLP protocol to observability backends.
5+
#
6+
# Usage:
7+
# 1. Install the OpenTelemetry Collector: https://opentelemetry.io/docs/collector/installation/
8+
# 2. Copy this file and adjust the configuration for your environment
9+
# 3. Run: otelcol --config otel-collector.yml
10+
#
11+
# For Docker:
12+
# docker run -v $(pwd)/otel-collector.yml:/etc/otelcol/config.yaml \
13+
# otel/opentelemetry-collector-contrib:latest
14+
15+
receivers:
16+
# Scrape Prometheus metrics from DBLab Engine
17+
prometheus:
18+
config:
19+
scrape_configs:
20+
- job_name: 'dblab'
21+
scrape_interval: 15s
22+
scrape_timeout: 10s
23+
static_configs:
24+
- targets: ['localhost:2345']
25+
# Optional: Add labels to identify this instance
26+
relabel_configs:
27+
- source_labels: []
28+
target_label: environment
29+
replacement: 'production'
30+
31+
# Optional: Collect host metrics
32+
hostmetrics:
33+
collection_interval: 30s
34+
scrapers:
35+
cpu:
36+
memory:
37+
disk:
38+
filesystem:
39+
network:
40+
41+
processors:
42+
# Batch metrics for efficient export
43+
batch:
44+
timeout: 10s
45+
send_batch_size: 1000
46+
47+
# Add resource attributes
48+
resource:
49+
attributes:
50+
- key: service.name
51+
value: dblab-engine
52+
action: upsert
53+
- key: service.version
54+
value: "3.0"
55+
action: upsert
56+
57+
# Optional: Filter or transform metrics
58+
filter:
59+
metrics:
60+
include:
61+
match_type: regexp
62+
metric_names:
63+
- dblab_.*
64+
65+
exporters:
66+
# Export to OTLP-compatible backends (Grafana Cloud, Datadog, etc.)
67+
otlp:
68+
endpoint: "your-otlp-endpoint:4317"
69+
tls:
70+
insecure: false
71+
headers:
72+
# Add authentication headers as needed
73+
# Authorization: "Bearer <token>"
74+
75+
# Alternative: Export to Prometheus remote write
76+
prometheusremotewrite:
77+
endpoint: "https://prometheus.example.com/api/v1/write"
78+
# tls:
79+
# ca_file: /path/to/ca.crt
80+
# headers:
81+
# Authorization: "Bearer <token>"
82+
83+
# Debug: Log metrics to console (useful for testing)
84+
debug:
85+
verbosity: detailed
86+
87+
# Alternative: Keep Prometheus format for local scraping
88+
prometheus:
89+
endpoint: "0.0.0.0:8889"
90+
namespace: dblab
91+
92+
extensions:
93+
health_check:
94+
endpoint: 0.0.0.0:13133
95+
96+
zpages:
97+
endpoint: 0.0.0.0:55679
98+
99+
service:
100+
extensions: [health_check, zpages]
101+
pipelines:
102+
metrics:
103+
receivers: [prometheus]
104+
processors: [batch, resource]
105+
# Choose your exporter(s):
106+
# - Use 'otlp' for OTLP-compatible backends
107+
# - Use 'prometheusremotewrite' for Prometheus remote write
108+
# - Use 'debug' for testing
109+
exporters: [debug]
110+
111+
telemetry:
112+
logs:
113+
level: info
114+
metrics:
115+
address: 0.0.0.0:8888

0 commit comments

Comments
 (0)