Health and Metrics

Asset Core daemons expose health endpoints for monitoring and Prometheus metrics for observability.

Overview

Both write and read daemons provide:

  • Health endpoint: JSON status for load balancers and monitoring
  • Metrics endpoint: Prometheus-format metrics for dashboards and alerting

Structure

Health Endpoints

DaemonEndpointDescription
WriteGET /v1/healthCommit log status and lag
ReadGET /v1/healthProjection freshness

Metrics Endpoints

DaemonEndpointFormat
WriteGET /v1/metricsPrometheus text
ReadGET /v1/metricsPrometheus text

Fields

Write Daemon Health

{
  "status": "healthy",
  "commit_log": {
    "end_seq": 1000,
    "checkpoint_seq": 1000,
    "lag": 0,
    "driver": {
      "name": "file",
      "path": "/var/lib/assetcore/commit_log.log"
    }
  }
}
FieldDescription
statushealthy or degraded
commit_log.end_seqLatest committed sequence
commit_log.checkpoint_seqLatest checkpointed sequence
commit_log.lagDifference (should be 0 or near 0)

Read Daemon Health

{
  "status": "healthy",
  "freshness": {
    "checkpoint_seq": 998,
    "commit_log_seq": 1000,
    "lag": 2
  }
}
FieldDescription
freshness.checkpoint_seqSequences applied to projection
freshness.commit_log_seqLatest in commit log
freshness.lagHow far behind the read daemon is

Key Metrics

Write Daemon

MetricTypeDescription
assetcore_write_requests_totalCounterTotal requests by route and status
assetcore_write_request_duration_secondsHistogramRequest latency
assetcore_write_commit_duration_secondsHistogramCommit-specific latency
assetcore_write_ingress_queue_depthGaugeItems waiting in queue
assetcore_write_ingress_inflightGaugeRequests being processed
assetcore_write_commit_log_end_seqGaugeLatest committed sequence
assetcore_write_commit_log_lagGaugeCheckpoint lag

Read Daemon

MetricTypeDescription
assetcore_read_requests_totalCounterTotal requests by route
assetcore_read_request_duration_secondsHistogramRequest latency
assetcore_read_checkpoint_seqGaugeApplied sequence
assetcore_read_freshness_lagGaugeEvents behind commit log
assetcore_read_snapshot_publish_duration_secondsHistogramSnapshot publish time

Examples

Check Write Health

curl http://localhost:8080/v1/health | jq .

Check Read Freshness

curl http://localhost:8081/v1/read/freshness | jq .

Scrape Metrics

Add to your Prometheus configuration:

scrape_configs:
  - job_name: 'assetcore-write'
    static_configs:
      - targets: ['localhost:8080']
    metrics_path: '/v1/metrics'

  - job_name: 'assetcore-read'
    static_configs:
      - targets: ['localhost:8081']
    metrics_path: '/v1/metrics'

Example Prometheus Queries

Request rate:

rate(assetcore_write_requests_total[5m])

P99 latency:

histogram_quantile(0.99, rate(assetcore_write_request_duration_seconds_bucket[5m]))

Read daemon lag:

assetcore_read_freshness_lag

Error rate:

rate(assetcore_write_requests_total{status!="200"}[5m])

Example Alerts

groups:
  - name: assetcore
    rules:
      - alert: HighReadLag
        expr: assetcore_read_freshness_lag > 100
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Read daemon is behind commit log"

      - alert: WriteQueueFull
        expr: assetcore_write_ingress_queue_depth > 900
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "Write queue approaching capacity"