OpenTelemetry (OTLP) Ingestion
MynaDB natively supports OpenTelemetry Protocol (OTLP) for ingesting metrics, logs, and traces. Send observability data directly from your applications, the OpenTelemetry Collector, or any OTLP-compatible agent without any additional adapters or translation layers.
MynaDB implements the OpenTelemetry Protocol (OTLP) v1.0 specification, supporting both gRPC and HTTP/protobuf transports. Any OpenTelemetry SDK or Collector that speaks OTLP can send data to MynaDB out of the box.
Supported Endpoints
MynaDB exposes the following OTLP endpoints for receiving telemetry data:
| Protocol | Endpoint | Method | Description |
|---|---|---|---|
| gRPC | :4317 |
- | Native gRPC OTLP receiver for all signal types (metrics, logs, traces) |
| HTTP | /v1/metrics |
POST | HTTP/protobuf endpoint for metrics ingestion |
| HTTP | /v1/logs |
POST | HTTP/protobuf endpoint for logs ingestion |
| HTTP | /v1/traces |
POST | HTTP/protobuf endpoint for traces ingestion |
Configuration
Enable and configure OTLP ingestion in your config.toml:
[otlp]
enabled = true
database = "otel" # Target database for OTLP data
grpc_port = 4317 # gRPC receiver port
http_enabled = true # Enable HTTP/protobuf endpoints
http_port = 4318 # HTTP receiver port (on main HTTP server if 0)
# Signal-specific configuration
[otlp.metrics]
enabled = true
table_name = "otel_metrics" # Table name for metrics data
resource_attributes_as_tags = true # Map resource attributes to tags
include_scope_info = true # Include instrumentation scope
[otlp.logs]
enabled = true
table_name = "otel_logs" # Table name for log records
body_field = "body" # Field name for log body
severity_as_tag = true # Map severity level to a tag
resource_attributes_as_tags = true
[otlp.traces]
enabled = true
table_name = "otel_traces" # Table name for trace spans
span_attributes_as_fields = true # Map span attributes to fields
resource_attributes_as_tags = true
include_events = true # Store span events as nested data
All OTLP data is written to the database specified by otlp.database (default: otel).
Within that database, each signal type is stored in its own table as configured by
table_name in the respective section.
Data Mapping
MynaDB automatically maps OTLP data structures into its time series storage model. Resource attributes become tags, and data points become fields in the corresponding tables.
Metrics Mapping
OTLP metrics are flattened into the otel_metrics table with the following schema:
| Column | Type | Source |
|---|---|---|
time |
TIMESTAMP | Data point timestamp |
metric_name |
STRING (tag) | OTLP metric name |
metric_type |
STRING (tag) | gauge, sum, histogram, summary |
value |
FLOAT | Metric value (gauge/sum) |
count |
INTEGER | Histogram/summary count |
sum |
FLOAT | Histogram/summary sum |
service_name |
STRING (tag) | Resource attribute: service.name |
host_name |
STRING (tag) | Resource attribute: host.name |
{attribute} |
STRING (tag) | Additional data point attributes |
Logs Mapping
OTLP log records are stored in the otel_logs table:
| Column | Type | Source |
|---|---|---|
time |
TIMESTAMP | Log record timestamp |
severity |
STRING (tag) | Severity level (INFO, WARN, ERROR, etc.) |
severity_number |
INTEGER | Numeric severity (1-24) |
body |
STRING | Log message body |
trace_id |
STRING | Associated trace ID (if present) |
span_id |
STRING | Associated span ID (if present) |
service_name |
STRING (tag) | Resource attribute: service.name |
{attribute} |
STRING (tag) | Additional log attributes |
Traces Mapping
OTLP trace spans are stored in the otel_traces table:
| Column | Type | Source |
|---|---|---|
time |
TIMESTAMP | Span start time |
trace_id |
STRING (tag) | Trace identifier |
span_id |
STRING | Span identifier |
parent_span_id |
STRING | Parent span identifier |
span_name |
STRING (tag) | Operation name |
span_kind |
STRING (tag) | INTERNAL, SERVER, CLIENT, PRODUCER, CONSUMER |
duration_ns |
INTEGER | Span duration in nanoseconds |
status_code |
STRING (tag) | OK, ERROR, UNSET |
status_message |
STRING | Status description (on error) |
service_name |
STRING (tag) | Resource attribute: service.name |
{attribute} |
STRING | Span attributes as fields |
OpenTelemetry Collector
The recommended way to send OTLP data to MynaDB is through the OpenTelemetry Collector. Configure MynaDB as an OTLP exporter in your collector pipeline:
# otel-collector-config.yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
# Example: scrape Prometheus metrics and forward as OTLP
prometheus:
config:
scrape_configs:
- job_name: 'node-exporter'
scrape_interval: 15s
static_configs:
- targets: ['localhost:9100']
processors:
batch:
timeout: 5s
send_batch_size: 1000
memory_limiter:
check_interval: 1s
limit_mib: 512
resource:
attributes:
- key: environment
value: production
action: upsert
exporters:
otlp/mynadb:
endpoint: mynadb-host:4317
tls:
insecure: true # Set to false in production with TLS
retry_on_failure:
enabled: true
initial_interval: 5s
max_interval: 30s
sending_queue:
enabled: true
num_consumers: 4
queue_size: 1000
service:
pipelines:
metrics:
receivers: [otlp, prometheus]
processors: [memory_limiter, batch, resource]
exporters: [otlp/mynadb]
logs:
receivers: [otlp]
processors: [memory_limiter, batch, resource]
exporters: [otlp/mynadb]
traces:
receivers: [otlp]
processors: [memory_limiter, batch, resource]
exporters: [otlp/mynadb]
Running the Collector
# Docker
docker run -d --name otel-collector \
-v ./otel-collector-config.yaml:/etc/otelcol/config.yaml \
-p 4317:4317 \
-p 4318:4318 \
otel/opentelemetry-collector-contrib:latest
# Binary
otelcol-contrib --config otel-collector-config.yaml
Direct SDK Integration
You can also send OTLP data directly from your application using any OpenTelemetry SDK:
# Python example - sending metrics directly to MynaDB
from opentelemetry import metrics
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
# Configure OTLP exporter pointing to MynaDB
exporter = OTLPMetricExporter(
endpoint="mynadb-host:4317",
insecure=True,
)
reader = PeriodicExportingMetricReader(exporter, export_interval_millis=10000)
provider = MeterProvider(metric_readers=[reader])
metrics.set_meter_provider(provider)
# Create and record metrics
meter = metrics.get_meter("myapp")
counter = meter.create_counter("http_requests", description="Total HTTP requests")
histogram = meter.create_histogram("request_duration_ms", description="Request latency")
counter.add(1, {"method": "GET", "path": "/api/users", "status": "200"})
histogram.record(42.5, {"method": "GET", "path": "/api/users"})
Querying OTLP Data
Once ingested, OTLP data is stored as regular MynaDB tables and can be queried using standard SQL. Here are common query patterns for each signal type.
Querying Metrics
-- Average CPU usage per service over the last hour
SELECT
service_name,
metric_name,
time_bucket('5 minutes', time) AS bucket,
AVG(value) AS avg_value,
MAX(value) AS max_value
FROM otel.default.otel_metrics
WHERE metric_name = 'system.cpu.utilization'
AND time > now() - INTERVAL '1 hour'
GROUP BY service_name, metric_name, bucket
ORDER BY bucket DESC;
-- Top 10 services by request count
SELECT
service_name,
SUM(value) AS total_requests
FROM otel.default.otel_metrics
WHERE metric_name = 'http_requests'
AND time > now() - INTERVAL '24 hours'
GROUP BY service_name
ORDER BY total_requests DESC
LIMIT 10;
Querying Logs
-- Recent error logs across all services
SELECT
time,
service_name,
severity,
body
FROM otel.default.otel_logs
WHERE severity = 'ERROR'
AND time > now() - INTERVAL '1 hour'
ORDER BY time DESC
LIMIT 50;
-- Error rate by service over time
SELECT
service_name,
time_bucket('15 minutes', time) AS bucket,
COUNT(*) FILTER (WHERE severity = 'ERROR') AS errors,
COUNT(*) AS total,
ROUND(100.0 * COUNT(*) FILTER (WHERE severity = 'ERROR') / COUNT(*), 2) AS error_pct
FROM otel.default.otel_logs
WHERE time > now() - INTERVAL '6 hours'
GROUP BY service_name, bucket
ORDER BY bucket DESC;
Querying Traces
-- Slowest endpoints in the last hour
SELECT
service_name,
span_name,
COUNT(*) AS span_count,
AVG(duration_ns / 1000000.0) AS avg_ms,
MAX(duration_ns / 1000000.0) AS max_ms,
APPROX_PERCENTILE_CONT(duration_ns / 1000000.0, 0.99) AS p99_ms
FROM otel.default.otel_traces
WHERE span_kind = 'SERVER'
AND time > now() - INTERVAL '1 hour'
GROUP BY service_name, span_name
ORDER BY p99_ms DESC
LIMIT 20;
-- Trace waterfall - all spans for a specific trace
SELECT
span_name,
span_kind,
service_name,
duration_ns / 1000000.0 AS duration_ms,
status_code,
parent_span_id,
span_id
FROM otel.default.otel_traces
WHERE trace_id = '4bf92f3577b34da6a3ce929d0e0e4736'
ORDER BY time ASC;
-- Error spans by service
SELECT
service_name,
span_name,
COUNT(*) AS error_count,
MIN(time) AS first_seen,
MAX(time) AS last_seen
FROM otel.default.otel_traces
WHERE status_code = 'ERROR'
AND time > now() - INTERVAL '24 hours'
GROUP BY service_name, span_name
ORDER BY error_count DESC;
Cross-Signal Correlation
-- Find error logs associated with slow traces
SELECT
t.trace_id,
t.span_name,
t.duration_ns / 1000000.0 AS duration_ms,
l.severity,
l.body AS log_message
FROM otel.default.otel_traces t
JOIN otel.default.otel_logs l
ON t.trace_id = l.trace_id
WHERE t.duration_ns > 5000000000 -- spans longer than 5 seconds
AND l.severity IN ('ERROR', 'WARN')
AND t.time > now() - INTERVAL '1 hour'
ORDER BY t.duration_ns DESC
LIMIT 25;
For best query performance on OTLP data, always include a time range filter
(time > now() - INTERVAL '...') to leverage date-based partition pruning.
Tag columns like service_name and metric_name are indexed and
efficient for filtering.