Logstreem
Node SDK

Node SDK

A typed client with batching, retries and webhook verification.

Install
npm install @logstreem/node
import { Logstreem } from "@logstreem/node";

const logstreem = new Logstreem({
  token: process.env.LOGSTREEM_TOKEN!,
  dataset: "api-gateway-prod",
  // Buffers and flushes for you; both are the defaults.
  batchSize: 1000,
  flushIntervalMs: 2000,
});

// Fire and forget — buffered, never blocks the request path.
logstreem.log({ level: "error", service: "checkout", status: 503, latency: 3814 });

// Query
const result = await logstreem.query(`
  ['api-gateway-prod']
  | where status >= 500
  | summarize errors = count() by service
`);

console.table(result.rows);

// Flush on shutdown or you lose the tail.
process.on("beforeExit", () => logstreem.flush());

Always flush on shutdown

The buffer is what makes logging cheap; it is also what loses your last two seconds of events if the process exits without flushing. In a container, wire it to SIGTERM as well as beforeExit.