Metrics

Causet services expose Prometheus-compatible metrics through Spring Boot Actuator. Scrape the /actuator/prometheus endpoint on each service.


Prometheus scrape endpoint

GET /actuator/prometheus

Add each service to your prometheus.yml scrape config:

# infra/prometheus/prometheus.yml
scrape_configs:
  - job_name: causet-runtime-service
    static_configs:
      - targets: ['causet-runtime-service:8080']
    metrics_path: /actuator/prometheus
 
  - job_name: causet-projection-worker
    static_configs:
      - targets: ['causet-projection-worker:8083']
    metrics_path: /actuator/prometheus
 
  - job_name: causet-query-service
    static_configs:
      - targets: ['causet-query-service:8082']
    metrics_path: /actuator/prometheus
 
  - job_name: causet-saas-cloud
    static_configs:
      - targets: ['causet-saas-cloud:8085']
    metrics_path: /actuator/prometheus

Causet application metrics

Event throughput

MetricTypeLabelsDescription
causet_events_emitted_totalCounterevent_type, platform, application, forkTotal events written to the ledger
causet_events_processed_totalCounterevent_type, projection, forkTotal events processed by the projection worker
# Event emission rate (per event type, 1m window)
rate(causet_events_emitted_total[1m])

# Projection processing throughput
rate(causet_events_processed_total[1m])

Projection lag

MetricTypeLabelsDescription
causet_projection_lag_secondsHistogramprojection, forkTime from event emission to projection UPSERT completion
# P95 projection lag per projection
histogram_quantile(0.95,
  sum by (le, projection) (
    rate(causet_projection_lag_seconds_bucket[5m])
  )
)

# Average lag across all projections
rate(causet_projection_lag_seconds_sum[5m]) /
  rate(causet_projection_lag_seconds_count[5m])

Intent latency

MetricTypeLabelsDescription
causet_intent_latency_secondsHistogramaction, fork, statusEnd-to-end intent processing time (received → event committed)
# P99 intent latency per action
histogram_quantile(0.99,
  sum by (le, action) (
    rate(causet_intent_latency_seconds_bucket[5m])
  )
)

Handler duration

MetricTypeLabelsDescription
causet_handler_duration_secondsHistogramprojection, event_type, opTime spent in the projection handler UPSERT

Failures and retries

MetricTypeLabelsDescription
causet_projection_failures_totalCounterprojection, event_type, error_typeProjection handler failures
causet_retry_count_totalCounterprojection, event_typeTotal retry attempts
causet_dlq_messages_totalCounterprojection, event_typeMessages sent to DLQ
# Failure rate per projection (5m window)
rate(causet_projection_failures_total[5m])

# DLQ rate (any non-zero value is an alert)
rate(causet_dlq_messages_total[5m])

Kafka consumer lag

MetricTypeLabelsDescription
causet_kafka_consumer_lagGaugetopic, partition, consumer_groupUnprocessed messages in the projection event topic
causet_checkpoint_age_secondsGaugeconsumer_group, topicTime since last committed checkpoint
# Total lag across all partitions
sum(causet_kafka_consumer_lag{consumer_group="causet-projection-worker"})

# Lag growing over 10 minutes (early warning)
deriv(sum(causet_kafka_consumer_lag{consumer_group="causet-projection-worker"})[10m:1m]) > 0

JVM and infrastructure metrics

Spring Boot Actuator also exposes standard JVM and infrastructure metrics:

MetricDescription
jvm_memory_used_bytesJVM heap and non-heap memory usage
jvm_gc_pause_secondsGC pause duration histogram
jvm_threads_live_threadsLive thread count
hikaricp_connections_activeActive DB connections from connection pool
hikaricp_connections_pendingThreads waiting for a DB connection
hikaricp_connections_timeout_totalConnection acquisition timeouts
http_server_requests_secondsHTTP request latency histogram, per endpoint
process_cpu_usageCPU usage of the JVM process
# DB connection pool saturation (approaching limit is a warning)
hikaricp_connections_active / hikaricp_connections_max

# GC overhead
rate(jvm_gc_pause_seconds_sum[5m])

# HTTP error rate
rate(http_server_requests_seconds_count{status=~"5.."}[5m])

Alert thresholds

Configure these alerts in Grafana. These are starting points — tune based on your actual load.

AlertConditionSeverity
Projection lag highcauset_projection_lag_seconds P95 > 30sWARNING
Projection lag criticalcauset_projection_lag_seconds P95 > 5mCRITICAL
DLQ non-emptyrate(causet_dlq_messages_total[5m]) > 0WARNING
Projection failuresrate(causet_projection_failures_total[5m]) > 0WARNING
Kafka consumer lag growingderiv(causet_kafka_consumer_lag[10m]) > 100WARNING
DB connection pool near limithikaricp_connections_active / hikaricp_connections_max > 0.8WARNING
Service health downup{job="causet-runtime-service"} == 0CRITICAL
High intent latencycauset_intent_latency_seconds P95 > 2sWARNING

Sample Grafana alert rule:

- alert: CausetDLQNonEmpty
  expr: increase(causet_dlq_messages_total[5m]) > 0
  for: 0m
  labels:
    severity: warning
  annotations:
    summary: "DLQ received messages in the last 5 minutes"
    description: "Projection {{ $labels.projection }} sent {{ $value }} messages to DLQ"

Grafana dashboard

Import the dashboard template from infra/prometheus/dashboards/causet-overview.json. It includes panels for all key metrics listed above.

See Dashboards for panel descriptions and setup instructions.