Skip to content

LogTailer Agent

The LogTailer is the entry point of the pipeline. It continuously monitors Cloudflare Workers for errors.

  • Poll Workers Observability API every 30 seconds
  • Classify errors by HTTP status code
  • Compute SHA-256 fingerprints with normalization
  • Deduplicate errors using agent-local SQLite
  • Create incidents in D1 and publish to the errors-detected queue
  1. Load all enabled service configs from D1
  2. For each service, query Workers Observability with a 60-second lookback window
  3. Use a 15-second overlap to handle eventual consistency
  4. Process each event through the fingerprinting pipeline

Each error is fingerprinted using:

sha256(serviceName | normalizedMessage | triggerRoute | topStackFrames)

Normalization strips dynamic values (UUIDs, timestamps, JWTs, emails, numeric IDs) so that the same root cause always produces the same fingerprint.

ConditionAction
New fingerprintCreate D1 incident + publish to queue
Known, resolved >24h agoReopen incident + re-queue
Known, activeIncrement occurrence count
Known, wontfixIncrement count only

The LogTailer creates two tables in its embedded SQLite:

  • error_fingerprints — fingerprint → incident mapping with status and timestamps
  • poll_cursors — per-service cursor tracking the last processed timestamp

This allows sub-millisecond dedup lookups without hitting D1.

MethodPathDescription
GET/statusCurrent polling state and stats
POST/pollTrigger an immediate poll
POST/startStart the polling loop
POST/stopStop the polling loop

src/agents/log-tailer.ts