NEW IN v0.3.0

Monitoring & Observability

Comprehensive monitoring with Prometheus metrics, query tracing, and system health endpoints. Gain full visibility into MynaDB's performance, resource usage, and operational health to keep your time series infrastructure running smoothly.

📈 Full Observability Stack

MynaDB exposes Prometheus-compatible metrics, structured health endpoints, slow query tracing, and self-reported system metrics. Pair with Grafana for a complete monitoring and visualization solution.

Prometheus Metrics

MynaDB exposes a /metrics endpoint in the Prometheus exposition format. Scrape this endpoint to collect detailed metrics about writes, queries, cache performance, storage, and background operations.

Endpoint

bash
# Fetch Prometheus metrics
curl http://localhost:7000/metrics

Prometheus Scrape Configuration

Add MynaDB as a scrape target in your prometheus.yml:

yaml
scrape_configs:
  - job_name: 'mynadb'
    scrape_interval: 15s
    static_configs:
      - targets: ['localhost:7000']
        labels:
          instance: 'mynadb-prod-01'

  # For a cluster deployment, add all nodes
  - job_name: 'mynadb-cluster'
    scrape_interval: 15s
    static_configs:
      - targets:
          - 'node1:7000'
          - 'node2:7000'
          - 'node3:7000'

Key Metrics

Metric Type Description
mynadb_writes_total Counter Total number of write requests received
mynadb_write_bytes_total Counter Total bytes written (line protocol payload size)
mynadb_queries_total Counter Total number of SQL queries executed
mynadb_query_duration_seconds Histogram Query execution duration in seconds (buckets: 0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10)
mynadb_cache_hits_total Counter Total number of cache hits (metadata + query cache)
mynadb_cache_misses_total Counter Total number of cache misses
mynadb_storage_bytes Gauge Current total storage usage in bytes across all catalogs
mynadb_compaction_runs_total Counter Total number of compaction runs completed
mynadb_active_connections Gauge Number of currently active client connections (HTTP, Flight, MySQL)
mynadb_flush_duration_seconds Histogram Duration of cache flush operations to Parquet (seconds)

Example Metric Output

text
# HELP mynadb_writes_total Total number of write requests
# TYPE mynadb_writes_total counter
mynadb_writes_total{catalog="mydb"} 158432

# HELP mynadb_query_duration_seconds Query execution duration
# TYPE mynadb_query_duration_seconds histogram
mynadb_query_duration_seconds_bucket{le="0.01"} 12045
mynadb_query_duration_seconds_bucket{le="0.05"} 34210
mynadb_query_duration_seconds_bucket{le="0.1"} 45123
mynadb_query_duration_seconds_bucket{le="0.25"} 48900
mynadb_query_duration_seconds_bucket{le="0.5"} 49800
mynadb_query_duration_seconds_bucket{le="1"} 49950
mynadb_query_duration_seconds_bucket{le="+Inf"} 50000
mynadb_query_duration_seconds_sum 1523.45
mynadb_query_duration_seconds_count 50000

# HELP mynadb_storage_bytes Current storage usage in bytes
# TYPE mynadb_storage_bytes gauge
mynadb_storage_bytes{catalog="mydb",schema="default"} 10737418240

Health Endpoints

MynaDB provides several HTTP endpoints for health checks, load balancer integration, and operational visibility. These endpoints return JSON responses and do not require authentication.

Endpoint Method Description
GET /health GET Basic health check. Returns 200 OK when the server is running. Use for load balancer probes.
GET /stats GET Write cache statistics: current size, entry count, flush status, and buffer utilization.
GET /memory GET Memory usage breakdown: heap allocated, RSS, cache sizes, and buffer pool usage.
GET /cache/stats GET Cache hit/miss rates for both metadata cache and query result cache.

Health Check

bash
# Basic health check
curl http://localhost:7000/health

# Response:
# {"status": "ok"}

Write Cache Stats

bash
curl http://localhost:7000/stats

# Response:
{
  "cache_size_bytes": 52428800,
  "cache_entries": 1250,
  "max_size_bytes": 4294967296,
  "utilization_pct": 1.22,
  "last_flush": "2026-02-13T10:30:00Z",
  "flush_interval_secs": 60
}

Memory Usage

bash
curl http://localhost:7000/memory

# Response:
{
  "rss_bytes": 536870912,
  "heap_allocated_bytes": 268435456,
  "write_cache_bytes": 52428800,
  "metadata_cache_bytes": 16777216,
  "query_cache_bytes": 33554432
}

Cache Hit Rates

bash
curl http://localhost:7000/cache/stats

# Response:
{
  "metadata_cache": {
    "hits": 45230,
    "misses": 1280,
    "hit_rate": 0.972,
    "size_bytes": 16777216,
    "entries": 342
  },
  "query_cache": {
    "hits": 12450,
    "misses": 8320,
    "hit_rate": 0.599,
    "size_bytes": 33554432,
    "entries": 89,
    "ttl_secs": 300
  }
}

Query Tracing

MynaDB supports slow query logging and trace ID propagation for debugging query performance issues. Slow queries are automatically logged with execution details, enabling you to identify and optimize problematic queries.

Slow Query Logging Configuration

toml
[logging]
level = "info"
log_dir = "/data0/mynadb/logs"

# Slow query threshold (milliseconds)
# Queries exceeding this duration are logged at WARN level
slow_query_threshold_ms = 500

# Include execution plan in slow query logs
slow_query_log_plan = true

Slow Query Log Output

text
WARN  query: Slow query detected
  catalog=mydb
  sql="SELECT * FROM cpu WHERE time > now() - interval '1 hour' ORDER BY time DESC"
  duration_ms=1523
  rows_returned=48200
  partitions_scanned=3
  files_scanned=12
  trace_id=abc123def456

Trace ID Propagation

Pass a trace ID via the X-Trace-Id header to correlate queries across your observability stack. The trace ID is included in log entries, metric labels, and error responses for end-to-end tracing.

bash
# Pass a trace ID with your query
curl -H "X-Trace-Id: req-abc123" \
  "http://localhost:7000/query/mydb?sql=SELECT+count(*)+FROM+cpu"

# The trace ID appears in logs, allowing correlation
# with upstream services and distributed tracing systems
🔗 OpenTelemetry Integration

MynaDB also supports OpenTelemetry (OTLP) trace context propagation via the traceparent header (W3C Trace Context). This enables seamless integration with distributed tracing systems like Jaeger, Zipkin, and Grafana Tempo.

System Metrics Collection

MynaDB self-reports key system-level metrics covering CPU, memory, disk, and network. These metrics are included in the /metrics endpoint and provide visibility into the host environment without requiring a separate node exporter.

⚡

CPU

Process CPU usage percentage, number of cores used, and system load averages. Metric: mynadb_process_cpu_usage

💻

Memory

Resident set size (RSS), heap allocation, and virtual memory. Metric: mynadb_process_memory_bytes

💾

Disk

Data directory disk usage, available space, and I/O throughput. Metric: mynadb_disk_usage_bytes

🌐

Network

Bytes sent/received, active connections per protocol (HTTP, Flight, MySQL). Metric: mynadb_network_bytes_total

System Metrics Table

Metric Type Labels Description
mynadb_process_cpu_usage Gauge - Process CPU usage as a percentage (0-100)
mynadb_process_memory_bytes Gauge type (rss, heap, virtual) Process memory usage in bytes
mynadb_disk_usage_bytes Gauge state (used, available) Data directory disk usage
mynadb_disk_io_bytes_total Counter direction (read, write) Cumulative disk I/O in bytes
mynadb_network_bytes_total Counter direction (rx, tx) Cumulative network bytes transferred
mynadb_open_file_descriptors Gauge - Number of open file descriptors

Alerting Rules

Use Prometheus alerting rules to get notified about potential issues before they affect your workloads. The following examples cover common scenarios for MynaDB deployments.

yaml
groups:
  - name: mynadb_alerts
    rules:
      # Alert when query latency p99 exceeds 5 seconds
      - alert: MynaDBHighQueryLatency
        expr: |
          histogram_quantile(0.99,
            rate(mynadb_query_duration_seconds_bucket[5m])
          ) > 5
        for: 10m
        labels:
          severity: warning
        annotations:
          summary: "High query latency on {{ $labels.instance }}"
          description: "p99 query latency is {{ $value | humanizeDuration }} (threshold: 5s)"

      # Alert when cache hit rate drops below 80%
      - alert: MynaDBLowCacheHitRate
        expr: |
          rate(mynadb_cache_hits_total[5m])
          / (rate(mynadb_cache_hits_total[5m]) + rate(mynadb_cache_misses_total[5m]))
          < 0.8
        for: 15m
        labels:
          severity: warning
        annotations:
          summary: "Low cache hit rate on {{ $labels.instance }}"
          description: "Cache hit rate is {{ $value | humanizePercentage }} (threshold: 80%)"

      # Alert when disk usage exceeds 85%
      - alert: MynaDBDiskUsageHigh
        expr: |
          mynadb_disk_usage_bytes{state="used"}
          / (mynadb_disk_usage_bytes{state="used"} + mynadb_disk_usage_bytes{state="available"})
          > 0.85
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Disk usage critical on {{ $labels.instance }}"
          description: "Disk usage is {{ $value | humanizePercentage }}. Consider adjusting retention or adding storage."

      # Alert when no writes are received for 5 minutes
      - alert: MynaDBNoWrites
        expr: |
          rate(mynadb_writes_total[5m]) == 0
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "No writes on {{ $labels.instance }}"
          description: "MynaDB has not received any write requests in the last 5 minutes."

      # Alert when compaction is backed up
      - alert: MynaDBCompactionBacklog
        expr: |
          mynadb_storage_bytes > 50e9
          and rate(mynadb_compaction_runs_total[1h]) == 0
        for: 30m
        labels:
          severity: warning
        annotations:
          summary: "Compaction stalled on {{ $labels.instance }}"
          description: "No compaction runs in the last 30 minutes with >50GB storage."

      # Alert when instance is down
      - alert: MynaDBInstanceDown
        expr: up{job="mynadb"} == 0
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "MynaDB instance {{ $labels.instance }} is down"
          description: "The MynaDB instance has been unreachable for more than 1 minute."

Recording Rules

Pre-compute frequently used expressions as recording rules to improve dashboard performance:

yaml
groups:
  - name: mynadb_recording_rules
    rules:
      # Write rate per second
      - record: mynadb:writes_per_second
        expr: rate(mynadb_writes_total[5m])

      # Query rate per second
      - record: mynadb:queries_per_second
        expr: rate(mynadb_queries_total[5m])

      # Cache hit rate
      - record: mynadb:cache_hit_rate
        expr: |
          rate(mynadb_cache_hits_total[5m])
          / (rate(mynadb_cache_hits_total[5m]) + rate(mynadb_cache_misses_total[5m]))

      # p50 query latency
      - record: mynadb:query_latency_p50
        expr: histogram_quantile(0.5, rate(mynadb_query_duration_seconds_bucket[5m]))

      # p99 query latency
      - record: mynadb:query_latency_p99
        expr: histogram_quantile(0.99, rate(mynadb_query_duration_seconds_bucket[5m]))

Grafana Dashboard

Visualize all of these metrics using pre-built Grafana dashboards. MynaDB provides a comprehensive dashboard template that includes panels for write/query throughput, latency distributions, cache performance, storage usage, and system resource utilization.

✅ Ready-Made Dashboard

See the Grafana Integration guide for step-by-step instructions on setting up data sources, importing the MynaDB dashboard, and configuring alerts within Grafana.

📊

Write Throughput

Requests/sec and bytes/sec ingestion rate with trend lines

⏱

Query Latency

p50, p95, p99 latency histograms and percentile distributions

🚀

Cache Performance

Hit/miss rates, eviction counts, and memory utilization

🗃

Storage Overview

Disk usage trends, compaction progress, and partition counts

🛈 Related Guides

Grafana Integration - Dashboard setup and visualization
Configuration - Full configuration reference
Troubleshooting - Diagnosing common issues
Admin Console - Built-in web management UI