Skip to content

Recipes & Cookbook

Copy these four production-tested configurations directly into config.yml to capture AI-ready full-context incident packs.


Recipe 1: Four-Pillar Microservice Triage (APM + Logs + Host Forensics)

Section titled “Recipe 1: Four-Pillar Microservice Triage (APM + Logs + Host Forensics)”

Problem: A critical API suddenly suffers P99 spikes or 5xx bursts, forcing engineers to bounce across metrics dashboards, distributed traces, log search, and SSH top.

global:
interval: 5s
eval_interval: 1s
before: 60s
after: 20s
inputs:
host:
- id: default
log_file:
- id: order_app
path: /var/log/order/app.log
apm:
- id: order_svc
http_listen: "127.0.0.1:4318"
slow_threshold_ms: 500
alerts:
- id: order_p99_or_err_burst
severity: critical
for: 15s
expr: 'last("apm.order_svc.latency_p99_ms") > 1000 || log_count("log_file.order_app", "ERROR|panic", 60) >= 5'
attach: ["host/default"]

What gets captured:

  • One self-contained Markdown file combining:
    1. Full-precision pre/post metric curves for apm/order_svc and host/default;
    2. Top slow/error trace waterfalls (with HTTP/RPC/DB attributes and stack traces);
    3. Matching order_app log lines correlated via trace_id;
    4. T0 host Top processes.
  • Hand it to Ketos Cloud AI or your local AI Agent to distinguish slow SQL, upstream timeouts, and host saturation in seconds.

Recipe 2: Catching Short-Lived CPU / Memory Spike Culprits

Section titled “Recipe 2: Catching Short-Lived CPU / Memory Spike Culprits”

Problem: A 3 AM CPU or memory alert fires, but by the time you SSH in to run top, the runaway batch job or leaking process has already exited or been killed by the OOM killer.

global:
interval: 2s
eval_interval: 1s
before: 60s
after: 20s
inputs:
host:
- id: default
top_processes_limit: 15
alerts:
- id: cpu_or_mem_spike
severity: critical
for: 10s
expr: 'avg("cpu.usage_pct", 30) > 85 || last("mem.usage_pct") > 85'

What gets captured:

  • At T=0, scans the process table once and ranks processes by the triggering dimension (CPU, memory, or deduplicated Top CPU + Top Memory for compound rules).
  • Saves data/snapshots/cpu_or_mem_spike/host_default_<ts>_firing.md with complete pre/post resource curves and the culprit process still caught in the act.

Recipe 3: Correlating Remote API Latency with Local Host & Network Health

Section titled “Recipe 3: Correlating Remote API Latency with Local Host & Network Health”

Problem: A remote API times out intermittently and you need to know whether the bottleneck is DNS/TLS, remote TTFB, or local NIC drops and CPU saturation.

global:
interval: 5s
eval_interval: 1s
inputs:
host:
- id: default
http_probe:
- id: checkout_api
url: https://api.example.com/v1/health
timeout: 3s
expected_status: 200
alerts:
# Availability alert: captures only checkout_api metrics
- id: checkout_api_down
severity: critical
for: 10s
expr: 'last("http_probe.checkout_api.up") == 0'
# Slow-response alert: attaches local host/default metrics and Top processes
- id: checkout_api_slow
severity: warning
for: 15s
before: 120s
after: 30s
expr: 'avg("http_probe.checkout_api.latency_ms", 60) > 1200'
attach: ["host/default"]

Result: checkout_api_slow produces one .md file with ## Metrics: http_probe/checkout_api, ## Metrics: host/default, and ## Forensic: host/top_processes, making root-cause attribution immediate.


Recipe 4: 30 MB Flash-Safe Autonomy for Edge / IoT Devices

Section titled “Recipe 4: 30 MB Flash-Safe Autonomy for Edge / IoT Devices”

Problem: Retail or industrial edge boxes have small SD cards, limited RAM, and flaky connectivity, yet still need reliable host monitoring from inside a container.

global:
interval: 5s
eval_interval: 2s
before: 30s
after: 10s
inputs:
host:
- id: edge_box
root_path: /hostfs
mount_point: /
top_processes_limit: 10
alerts:
- id: edge_disk_full
severity: critical
every: 15s
for: 30s
expr: 'last("host.edge_box.disk.usage_pct") > 85 || last("host.edge_box.disk.inode_usage_pct") > 85'
- id: edge_mem_oom_risk
severity: critical
for: 10s
expr: 'last("host.edge_box.mem.usage_pct") > 90'
storage:
dir: /var/lib/ketos-agent
max_disk_mb: 30
max_snapshots: 200

Result: Zero steady-state disk writes; full offline autonomy with storage strictly capped at 30 MB / 200 snapshots via FIFO eviction.