{
  "id": 11583941,
  "title": "Express Node.js Structured Logs — Poll Error Search for 30-Day Cost Attribution",
  "url": "https://urgent.news/2026/10/03/express-node-js-structured-logs-poll-error-search-for-30-day-cost",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-03T02:45:37.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/theodorhawkins9251/express-nodejs-structured-logs-poll-error-search-for-30-day-cost-attribution-484"
  },
  "original_language": "en",
  "account": "The article discusses a structured logging approach for an Express Node.js service that utilizes AI-agent step completion. The service should send structured logs for each completed step, which includes relevant information such as tenant ID, workflow ID, run ID, step ID, model identifier, token counts, latency, and outcome. The logs should be concise, focusing on the essential fields necessary for diagnosis and attribution.\n\nKey points include:\n1. Sentient the Express service to emit logs after each step completes, ensuring duration, outcome, and usage metrics are known.\n2. Include relevant fields such as tenant ID, workflow ID, run ID, step ID, model identifier, input and output token counts, elapsed milliseconds, and outcome.\n3. Add an error class and sanitized error message for failure events.\n4. Retain only the necessary fields, excluding bulky request and response bodies to minimize storage costs.\n5. Consider three logical classes of events: attribution events (longer retention for reconciliation and trend comparisons), diagnostic excerpts (shorter retention and stricter access), and alert-delivery records (fingerprint, attempt state, and destination response category).\n6. Store sanitized failure details for debugging specific runs, but avoid storing full conversational content.\n7. Measure latency for the entire agent run and individual steps separately, without adding step durations to the wall-clock latency.\n8. Use stable names and explicit units for fields, following Prometheus naming guidance for consistency in log-to-metric transformations.",
  "summary": "Short answer: have the Express Node.js service send structured logs for every completed AI-agent step, then poll the log search for new error events and trigger deduplicated Slack notifications. Attach stable tenant, run, model, token, latency, and outcome fields. For a B2B SaaS agent, keep the small attribution fields longer than bulky request and response bodies. This is the least complex…",
  "key_points": [
    "Express Node.js service structured logs for each step completion",
    "Differentiate event classes: attribution, diagnostic, and alert-delivery records"
  ],
  "editors_take": "This logging approach enables more efficient error search and cost attribution by providing concise, relevant information for diagnosis and analysis, while minimizing storage costs.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}