Prometheus Metrics
All metrics are exposed atGET /api/metrics in Prometheus text format. Scrape this endpoint from your Prometheus server or any compatible collector. Default metrics (Node.js process stats) are auto-collected with the kaireon_ prefix.
Key Metrics
Rate Limiting
The platform uses a sliding window algorithm to enforce per-key request limits. Each request timestamp is recorded; when the count within the window exceeds the configured maximum, subsequent requests are rejected with429 Too Many Requests.
How It Works
- On each request, timestamps older than the window are pruned
- If the remaining count is at or above
maxRequests, the request is rejected - Otherwise the timestamp is recorded and the request proceeds
Storage Modes
Redis keys follow the pattern
ratelimit:sw:{key} with automatic expiry set to the window duration.
Response Headers
When a request is rate-limited, the API returns:
Each rate-limit decision exposes
allowed (boolean), remaining (requests left in the window), and retryAfterMs (set when the request is rejected) so callers can surface helpful retry guidance to clients.
Configuration
Rate limiters are instantiated with two parameters:If Redis is not configured (
REDIS_URL not set), rate limiting falls back to in-memory mode. The platform still works, but limits are per-process rather than global.Circuit Breakers
KaireonAI uses circuit breakers to prevent cascading failures when outbound integrations (connectors, webhooks, audit forwarding) become unavailable. (Scoring-model failures are handled separately by a per-request fallback — see Scoring Failure Fallback.)State Machine
Default Thresholds
Scoring Failure Fallback
The decision engine does not wrap scoring models in a stateful circuit breaker. Instead, a model error is caught per request and the engine applies a fallback score —0.5 * fitMultiplier for external scoring endpoints, or priority_weighted (priority / 100) when a model is missing — and sets degradedScoring: true on the response so decisions continue without interruption. There is no per-model cooldown or open/closed circuit state in the scoring stage.
Persistence
Circuit breaker state is persisted to Redis (key prefixkaireon:cb:) when REDIS_URL is set, so state survives process restarts. If Redis is unavailable, state is maintained in-memory only.
Where Circuit Breakers Are Used
The
/api/health endpoint reports all circuit breaker statuses. An open breaker sets health to degraded.
Prometheus Integration
Every state transition emits akaireon_circuit_breaker_state_change_total counter increment with labels name, from, and to. Alert on transitions to open:
Dead Letter Queue
Events that fail processing after retries are moved from the outbox to the dead letter queue (DLQ). DLQ entries are persisted, scoped per tenant, and organized by topic so admins can triage failed events by source.Admin API
GET /api/v1/admin/dlq — Retrieve DLQ summary and events (admin role required).
Response includes
totalEvents, a byTopic breakdown, the event list, and an alert field:
POST /api/v1/admin/dlq — Retry or purge DLQ events (admin role required).
- Retry re-enqueues events back to the outbox with
status: "pending"andretryCount: 0, then deletes the DLQ entry (transactional). - Purge permanently deletes matching DLQ events.
Monitoring
Track DLQ growth with thekaireon_dlq_depth gauge and outbox health with kaireon_outbox_event_age_seconds and kaireon_outbox_processed_total.
Cache Management
The platform caches offers, decisioning gates, and contact policies to reduce database load during decision execution. An emergency flush endpoint is available for situations where cached data becomes stale.POST /api/v1/admin/cache — Emergency cache invalidation (admin role required).
kaireon_cache_hits_total and kaireon_cache_misses_total.
Performance
KaireonAI applies several optimizations to keep decision latency low and pipeline throughput high.Decision Pipeline Caching
The decision engine caches frequently accessed data in Redis to avoid repeated database queries during recommendation processing:
Cache entries are automatically invalidated when the underlying entity is updated through the API.
Query Optimizations
- Creative queries are filtered by the set of candidate offer IDs, not loaded for the entire tenant. This prevents unbounded memory usage when a tenant has thousands of creatives across many offers.
- Flow route resolution is cached with a 120-second TTL, avoiding repeated database lookups for the same flow across concurrent requests.
Pipeline Throughput
- Chunked inserts — CSV ingestion writes to the database in batches of 1,000 rows, preventing memory exhaustion on large files and reducing transaction lock duration.
- Streaming batch execution — The batch executor uses summary counters (rows loaded, failed, skipped) instead of accumulating all row results in memory, allowing pipelines to process files larger than available RAM.
Decision Traces
Decision traces provide forensic visibility into every stage of the decision pipeline. Configure tracing in Settings > General > Retention > Decision Trace.
Traces are persisted to the decision-trace store and viewable from the Decision Flows detail page. Each trace records the full pipeline execution: candidates at each stage, filter reasons, scores, rankings, and timing breakdowns.
Monitoring Recipes
Latency Spiked
Decision latency suddenly increased. Identify which pipeline stage is the bottleneck:degradedScoring: true on the response payload (there is no scoring-failure counter emitted today).
Also check cache miss rates — a spike in misses can indicate a recent cache flush or deployment:
Conversion Dropped
Response outcomes stopped improving. Check delivery and outcome rates:DLQ Growing
The dead letter queue is accumulating events:- Check the DLQ admin endpoint (
GET /api/v1/admin/dlq) to identify failing topics - Investigate the root cause (downstream service outage, schema mismatch)
- Fix the underlying issue
- Retry events with
POST /api/v1/admin/dlqwithaction: "retry"
HTTP Error Rate Elevated
Monitor 4xx and 5xx error rates across all API routes:Related
Dashboards
Monitor platform health with the built-in dashboards.
Scaling & Deployment
Scaling configuration for multi-node deployments.
Troubleshooting
Common issues and resolution steps.
API Reference
Full API endpoint documentation.