Operations

Monitoring, replication, backup, and deployment for production context optimization workloads.


Monitoring

Prometheus Metrics

Nocturnus exposes 20+ metrics at GET /metrics in Prometheus format:

Track context payload efficiency from API responses too: monitor totalCharCount, totalFactsIncluded, and diff churn (added/removed) over time.

Grafana Dashboards

The Docker Compose profile includes pre-built Grafana dashboards:

# Start with monitoring stack
docker compose --profile monitoring up -d

# Open Grafana at http://localhost:3000
# Default credentials: admin / admin

Health Probes

Two endpoints for Kubernetes readiness and liveness:

# Liveness — confirms server is running
curl http://localhost:9300/health

# Readiness — confirms all subsystems are initialized
curl http://localhost:9300/health/ready

Logging

Nocturnus uses structured JSON logging via SLF4J. Configure via environment variables:

# .env
LOG_LEVEL=INFO          # DEBUG, INFO, WARN, ERROR
LOG_FORMAT=json         # json or plain

Every request gets a X-Request-ID response header for correlation.


Persistence

The in-memory Hexastore is persisted via Write-Ahead Log (WAL) and periodic snapshots:

# .env
STORAGE_DIR=/var/lib/nocturnusai/data   # WAL + snapshot directory

Replication

Nocturnus supports leader/follower replication via WAL streaming. Deploy read replicas to scale query load.

Leader

# .env (leader)
REPLICATION_MODE=LEADER
# The leader runs normally — no additional config needed

Follower

# .env (follower)
REPLICATION_MODE=FOLLOWER
LEADER_URL=http://leader-host:9300
REPLICATION_POLL_INTERVAL_MS=5000

Followers automatically poll the leader's WAL and apply changes locally. Queries against followers are eventually consistent.


Kubernetes Deployment

Example Kubernetes deployment with health checks:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nocturnusai
spec:
  replicas: 1
  template:
    spec:
      containers:
        - name: nocturnusai
          image: nocturnusai/server:latest
          ports:
            - containerPort: 9300
          livenessProbe:
            httpGet:
              path: /health
              port: 9300
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /health/ready
              port: 9300
            initialDelaySeconds: 5
            periodSeconds: 10
          env:
            - name: ANTHROPIC_API_KEY
              valueFrom:
                secretKeyRef:
                  name: nocturnusai-secrets
                  key: anthropic-api-key
          volumeMounts:
            - name: data
              mountPath: /var/lib/nocturnusai/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: nocturnusai-data

Agent-to-Agent Discovery

Nocturnus serves an Agent2Agent Protocol discovery card at GET /.well-known/agent.json. Other agents can automatically discover and interact with your fact database.


What's Next?

Security & Auth →

API keys, roles, and encryption

Multi-Tenancy →

Tenant isolation and scoped data

API Reference →

Health check and metrics endpoints