Statistics and Metrics Reference

Geode provides comprehensive statistics and metrics for monitoring, optimization, and observability. This reference documents all available metrics, collection methods, and integration options.

Overview

Metric Categories

CategoryPurposeCollection Method
Query StatisticsQuery performance analysisAutomatic
Storage StatisticsDisk and memory usageAutomatic
Index StatisticsIndex efficiencyAutomatic + Manual
Transaction StatisticsACID operationsAutomatic
Connection StatisticsClient connectionsAutomatic
System StatisticsResource utilizationAutomatic

Access Methods

  1. GQL Procedures: CALL db.stats.*
  2. Prometheus Endpoint: /metrics
  3. Admin API: REST endpoints
  4. EXPLAIN/PROFILE: Per-query metrics

Query Statistics

Global Query Statistics

-- View overall query statistics
CALL db.stats.queries();

Output:

MetricTypeDescription
total_queriesCounterTotal queries executed
successful_queriesCounterSuccessfully completed queries
failed_queriesCounterFailed queries
queries_in_progressGaugeCurrently executing queries
avg_query_time_msGaugeAverage query latency
p50_query_time_msGaugeMedian query latency
p95_query_time_msGauge95th percentile latency
p99_query_time_msGauge99th percentile latency
max_query_time_msGaugeMaximum observed latency

Query Type Breakdown

-- Statistics by query type
CALL db.stats.queries.by_type();
Query TypeDescription
MATCHRead queries
CREATENode/relationship creation
SETProperty updates
DELETEDeletions
MERGEUpsert operations
CALLProcedure calls

Slow Query Log

-- View slow queries (> threshold)
CALL db.stats.slow_queries(100);  -- threshold in ms

-- Configure slow query threshold
CALL db.config.set('query.slow_threshold_ms', 100);

Slow Query Entry:

{
  "timestamp": "2026-01-28T10:30:00Z",
  "query": "MATCH (p:Person)-[:KNOWS*5]->(f) RETURN f",
  "duration_ms": 1523,
  "rows_returned": 10000,
  "db_hits": 500000,
  "user": "alice",
  "client_ip": "192.168.1.100"
}

Query Plan Statistics

-- View cached query plans
CALL db.stats.query_plans();
MetricDescription
plan_cache_sizeNumber of cached plans
plan_cache_hitsCache hit count
plan_cache_missesCache miss count
plan_cache_hit_rateHit rate percentage
avg_plan_time_msAverage planning time

Storage Statistics

Database Size

-- Overall storage statistics
CALL db.stats.storage();

Output:

MetricTypeDescription
data_size_bytesGaugeTotal data file size
index_size_bytesGaugeTotal index size
wal_size_bytesGaugeWrite-ahead log size
total_size_bytesGaugeTotal disk usage
page_countGaugeTotal pages allocated
used_pagesGaugePages with data
free_pagesGaugeAvailable pages
fragmentation_ratioGaugeSpace fragmentation (0-1)

Graph Statistics

-- Graph element counts
CALL db.stats.graph();
MetricDescription
node_countTotal nodes
relationship_countTotal relationships
label_countDistinct node labels
relationship_type_countDistinct relationship types
property_key_countDistinct property keys

Label Statistics

-- Statistics per label
CALL db.stats.labels();

Per-label metrics:

MetricDescription
node_countNodes with this label
avg_property_countAverage properties per node
avg_relationship_countAverage relationships per node

Relationship Type Statistics

-- Statistics per relationship type
CALL db.stats.relationship_types();

Per-type metrics:

MetricDescription
countRelationships of this type
avg_property_countAverage properties per relationship

Index Statistics

Index Overview

-- All index statistics
CALL db.stats.indexes();

Per-index metrics:

MetricTypeDescription
index_nameStringIndex identifier
index_typeStringbtree, hash, fulltext, etc.
labelStringTarget label
propertyStringIndexed property
size_bytesGaugeIndex storage size
entry_countGaugeNumber of indexed entries
unique_valuesGaugeDistinct indexed values
null_countGaugeNULL entries
avg_values_per_keyGaugeAverage duplicates per key

Index Usage Statistics

-- Index usage metrics
CALL db.stats.index_usage();
MetricDescription
readsIndex read operations
scansFull index scans
seeksPoint lookups
range_scansRange query operations
updatesIndex update operations
last_usedTimestamp of last use

Index Health

-- Check index health
CALL db.stats.index_health('index_name');
MetricDescriptionHealthy Range
fragmentationInternal fragmentation< 0.3
depthTree depth (B-tree)< 5
fill_factorPage fill ratio> 0.7
bloom_false_positive_rateBloom filter FP rate< 0.01

Manual Statistics Update

-- Update statistics for all indexes
CALL db.stats.update();

-- Update statistics for specific label
CALL db.stats.update('Person');

-- Update specific index statistics
CALL db.index.analyze('person_email_idx');

Cardinality Estimation

The query optimizer uses cardinality estimates for cost-based optimization.

Histogram Statistics

-- View histograms for a property
CALL db.stats.histogram('Person', 'age');

Output:

ColumnDescription
bucket_minBucket lower bound
bucket_maxBucket upper bound
frequencyRow count in bucket
cumulative_frequencyCumulative row count
distinct_countDistinct values in bucket

Selectivity Estimates

-- Estimate predicate selectivity
CALL db.stats.selectivity('Person', 'age > 30');
MetricDescription
estimated_rowsRows matching predicate
selectivityFraction of total (0-1)
confidenceEstimate confidence (low/medium/high)

Statistics Configuration

statistics:
  auto_update: true
  update_threshold: 10000      # Update after N modifications
  sample_size: 1000            # Rows sampled for histograms
  histogram_buckets: 100       # Number of histogram buckets
  update_interval: 3600        # Auto-update interval (seconds)

Transaction Statistics

-- Transaction statistics
CALL db.stats.transactions();
MetricTypeDescription
active_transactionsGaugeCurrently open transactions
total_commitsCounterSuccessful commits
total_rollbacksCounterRollbacks
commit_rateGaugeCommits per second
avg_transaction_time_msGaugeAverage transaction duration
deadlock_countCounterDeadlock occurrences
lock_wait_time_msCounterTotal lock wait time

Lock Statistics

-- Current lock information
CALL db.stats.locks();
MetricDescription
active_locksCurrently held locks
waiting_locksLock requests waiting
lock_timeoutsLock timeout count
avg_lock_wait_msAverage lock wait time

Connection Statistics

-- Connection statistics
CALL db.stats.connections();
MetricTypeDescription
active_connectionsGaugeCurrently connected clients
total_connectionsCounterTotal connections (lifetime)
connection_errorsCounterFailed connection attempts
max_connectionsGaugeConnection limit
available_connectionsGaugeAvailable connection slots

Per-Client Statistics

-- Statistics per connected client
CALL db.stats.clients();
ColumnDescription
client_idClient identifier
userAuthenticated user
ip_addressClient IP
connected_atConnection timestamp
queries_executedQuery count for session
bytes_sentData sent to client
bytes_receivedData received from client

System Metrics

Resource Utilization

-- System resource metrics
CALL db.stats.system();
MetricTypeDescription
cpu_usage_percentGaugeCPU utilization
memory_used_bytesGaugeMemory in use
memory_available_bytesGaugeAvailable memory
memory_heap_bytesGaugeHeap memory usage
gc_pause_msHistogramGC pause times
gc_countCounterGC cycles

I/O Statistics

-- Disk I/O statistics
CALL db.stats.io();
MetricTypeDescription
read_bytesCounterBytes read from disk
write_bytesCounterBytes written to disk
read_opsCounterRead operations
write_opsCounterWrite operations
read_latency_msHistogramRead latency
write_latency_msHistogramWrite latency
fsync_countCounterfsync operations
fsync_latency_msHistogramfsync latency

Buffer Pool Statistics

-- Buffer pool metrics
CALL db.stats.buffer_pool();
MetricDescription
pool_size_pagesTotal buffer pool pages
used_pagesPages in use
dirty_pagesModified pages pending write
hit_rateBuffer cache hit rate
evictionsPage evictions
reads_from_diskCache misses

Prometheus Integration

Metrics Endpoint

Geode exposes metrics in Prometheus format at /metrics:

curl http://localhost:3141/metrics

Sample Output

# HELP geode_queries_total Total queries executed
# TYPE geode_queries_total counter
geode_queries_total{status="success"} 1234567
geode_queries_total{status="error"} 123

# HELP geode_query_duration_seconds Query execution time
# TYPE geode_query_duration_seconds histogram
geode_query_duration_seconds_bucket{le="0.001"} 10000
geode_query_duration_seconds_bucket{le="0.01"} 50000
geode_query_duration_seconds_bucket{le="0.1"} 100000
geode_query_duration_seconds_bucket{le="1.0"} 120000
geode_query_duration_seconds_bucket{le="+Inf"} 123456
geode_query_duration_seconds_sum 12345.67
geode_query_duration_seconds_count 123456

# HELP geode_connections_active Active client connections
# TYPE geode_connections_active gauge
geode_connections_active 42

# HELP geode_storage_bytes Storage size in bytes
# TYPE geode_storage_bytes gauge
geode_storage_bytes{type="data"} 1073741824
geode_storage_bytes{type="index"} 268435456
geode_storage_bytes{type="wal"} 134217728

# HELP geode_nodes_total Total nodes in database
# TYPE geode_nodes_total gauge
geode_nodes_total 1000000

# HELP geode_relationships_total Total relationships
# TYPE geode_relationships_total gauge
geode_relationships_total 5000000

Prometheus Configuration

# prometheus.yml
scrape_configs:
  - job_name: 'geode'
    static_configs:
      - targets: ['geode-server:3141']
    metrics_path: '/metrics'
    scrape_interval: 15s

Available Prometheus Metrics

Metric NameTypeLabelsDescription
geode_queries_totalCounterstatusTotal queries
geode_query_duration_secondsHistogram-Query latency
geode_connections_activeGauge-Active connections
geode_connections_totalCounter-Total connections
geode_transactions_totalCounterstatusTransaction count
geode_storage_bytesGaugetypeStorage usage
geode_nodes_totalGaugelabelNode count
geode_relationships_totalGaugetypeRelationship count
geode_index_size_bytesGaugeindexIndex sizes
geode_buffer_pool_hit_ratioGauge-Cache hit rate
geode_wal_size_bytesGauge-WAL size
geode_gc_pause_secondsHistogram-GC pauses

Alerting Guidelines

# Alert rules for Geode
groups:
  - name: geode_alerts
    rules:
      # High query latency
      - alert: GeodeHighQueryLatency
        expr: histogram_quantile(0.95, geode_query_duration_seconds_bucket) > 1
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "High query latency detected"

      # Connection pool exhaustion
      - alert: GeodeConnectionPoolLow
        expr: geode_connections_active / geode_connections_max > 0.9
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Connection pool nearly exhausted"

      # Storage space
      - alert: GeodeStorageHigh
        expr: geode_storage_bytes{type="data"} > 100e9
        for: 1h
        labels:
          severity: warning
        annotations:
          summary: "Database storage exceeds 100GB"

      # Buffer pool hit rate
      - alert: GeodeLowCacheHitRate
        expr: geode_buffer_pool_hit_ratio < 0.9
        for: 10m
        labels:
          severity: warning
        annotations:
          summary: "Buffer pool hit rate below 90%"

Grafana Dashboards

Key Panels

Query Performance:

  • Queries per second (rate)
  • Query latency percentiles (p50, p95, p99)
  • Slow query count
  • Error rate

Storage:

  • Database size growth
  • Index size breakdown
  • WAL size
  • Fragmentation ratio

Resources:

  • Buffer pool hit rate
  • Memory usage
  • I/O throughput
  • Connection count

Example Dashboard JSON

{
  "dashboard": {
    "title": "Geode Database",
    "panels": [
      {
        "title": "Query Rate",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(geode_queries_total[5m])",
            "legendFormat": "{{status}}"
          }
        ]
      },
      {
        "title": "Query Latency (p95)",
        "type": "graph",
        "targets": [
          {
            "expr": "histogram_quantile(0.95, rate(geode_query_duration_seconds_bucket[5m]))"
          }
        ]
      }
    ]
  }
}

Best Practices

Statistics Collection

  1. Enable auto-update for query optimizer accuracy
  2. Monitor slow queries with appropriate thresholds
  3. Track index usage to identify unused indexes
  4. Set up alerting for critical metrics

Performance Monitoring

  1. Baseline metrics during normal operation
  2. Track trends over time
  3. Correlate metrics (e.g., latency vs. connection count)
  4. Review after changes (schema, indexes, configuration)

Capacity Planning

  1. Monitor storage growth rate
  2. Track query volume trends
  3. Plan index storage needs
  4. Size buffer pool based on working set


Last Updated: January 28, 2026 Geode Version: v0.1.3+ Metrics Count: 50+ observable metrics