cluster_logs — Cluster Noisy Logs via Drain Prefix-Tree

Folds multi-line stack traces (JS/Java 'at ...', Python Traceback, Go panics, Java 'Caused by:'), parses plain-text, Docker/Kubernetes CRI, and NDJSON logs, pre-masks <UUID>/<IP>/<HEX>/<ISO_TS>/<URL>/<NUM>, and runs a fixed-depth Drain prefix-tree clusterer to collapse 50,000+ log lines by 95–99% with errorClusters highlighted first.

Why buy vs. DIY: Avoids naive grep/head truncation that misses rare fatal stack traces buried at line 41,000, cutting 500k-token log dumps to ~2k tokens in <50ms.

Pricing: $0.002 base (up to $0.008 max ($0.002 base + $0.001 per 2,000 log lines, capped at $0.008), x402 variable settlement) · REST: POST https://trace-diet.apikeg.com/v1/cluster-logs · MCP: https://trace-diet.apikeg.com/mcp

Input Parameters

FieldTypeRequired / DefaultDescription & Constraints
logs string Optional Raw plain-text, Docker/Kubernetes CRI, or newline-delimited JSON (ndjson) log stream. (minLength: 1, maxLength: 5000000)
lines array Optional Pre-split array of log lines (alternative to passing a single 'logs' string). (minItems: 1, maxItems: 100000)
similarityThreshold number Default: 0.6 Drain token-similarity threshold [0.2-1.0] required to merge a log line into an existing canonical template. (min: 0.2, max: 1)
treeDepth integer Default: 4 Fixed Drain prefix-tree depth (length -> leading tokens -> leaf templates). (min: 3, max: 8)
maxClusters integer Default: 300 Maximum canonical Drain clusters maintained before routing outliers to overflow. (min: 10, max: 1000)
maxReturnedClusters integer Default: 100 Maximum ranked clusters returned in the response payload. (min: 1, max: 500)
maxStackTraceChars integer Default: 1500 Maximum characters retained per cluster sampleStackTrace. (min: 128, max: 8192)

REST Example (curl)

curl -X POST "https://trace-diet.apikeg.com/v1/cluster-logs" \
  -H "Content-Type: application/json" \
  -d '{
  "similarityThreshold": 0.6,
  "treeDepth": 4,
  "maxClusters": 300,
  "maxReturnedClusters": 100,
  "maxStackTraceChars": 1500,
  "logs": "2026-11-30T08:00:01.100Z INFO [http] GET /healthz from 10.244.1.8 completed in 2ms\n2026-11-30T08:00:02.100Z INFO [http] GET /healthz from 10.244.1.9 completed in 3ms\n2026-11-30T08:00:03.250Z ERROR [db] Deadlock detected for tx 550e8400-e29b-41d4-a716-446655440000 after 3 retries\n    at PoolClient.query (/srv/app/db.ts:118:13)\n    at OrderRepo.commit (/srv/app/orders.ts:74:9)"
}'

MCP tools/call Payload

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "cluster_logs",
    "arguments": {
      "similarityThreshold": 0.6,
      "treeDepth": 4,
      "maxClusters": 300,
      "maxReturnedClusters": 100,
      "maxStackTraceChars": 1500,
      "logs": "2026-11-30T08:00:01.100Z INFO [http] GET /healthz from 10.244.1.8 completed in 2ms\n2026-11-30T08:00:02.100Z INFO [http] GET /healthz from 10.244.1.9 completed in 3ms\n2026-11-30T08:00:03.250Z ERROR [db] Deadlock detected for tx 550e8400-e29b-41d4-a716-446655440000 after 3 retries\n    at PoolClient.query (/srv/app/db.ts:118:13)\n    at OrderRepo.commit (/srv/app/orders.ts:74:9)"
    }
  }
}