sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ axiom/ index.mdx

Axiom is an event and observability store for logs, traces, and metrics. Effect already emits OpenTelemetry, and with alchemy the receiving end is code too: datasets, ingest tokens, monitors, notifiers, and dashboards live in the same Stack as the Workers and Functions they observe, so a threshold change is a reviewable diff.

New here? Set up credentials first.

Resources

A Dataset is the top-level container. Pick a kind per OTEL signal — it exposes the OTLP endpoints as outputs:

const traces  = yield* Axiom.Dataset("traces",  { name: "app-traces",  kind: "otel:traces:v1"  });
const logs    = yield* Axiom.Dataset("logs",    { name: "app-logs",    kind: "otel:logs:v1"    });
const metrics = yield* Axiom.Dataset("metrics", { name: "app-metrics", kind: "otel:metrics:v1" });

:::caution Renaming a dataset or changing its kind is a replacement — the old dataset and all its events are deleted. See Datasets & Ingest for details. :::

An ApiToken mints a least-privilege ingest credential for your runtime to ship with:

const ingest = yield* Axiom.ApiToken("ingest", {
  name: "prod-ingest",
  datasetCapabilities: {
    "app-traces": { ingest: ["create"] },
  },
});

Monitor + Notifier turn queries into alerts — see Monitors & Alerting for threshold and anomaly monitors:

const slack = yield* Axiom.Notifier("ops-slack", {
  name: "ops-channel",
  properties: {
    slack: { slackUrl: process.env.SLACK_WEBHOOK_URL! },
  },
});

yield* Axiom.Monitor("panics", {
  name: "Service panic",
  type: "MatchEvent",
  aplQuery: `['app-logs'] | where message contains "panic:"`,
  intervalMinutes: 1,
  rangeMinutes: 1,
  notifierIds: [slack.id],
});

Beyond alerts, Dashboard declares charts as code, View saves an APL query as a virtual dataset, and Annotation marks deploys on your charts — see Dashboards as Code. VirtualField derives computed fields on a dataset at query time.

Compose with your cloud

Wire the dataset's OTLP endpoints and the ingest token into your Worker or Lambda's environment, and Effect's OpenTelemetry output flows into Axiom with no code changes — see Observability for the exporter-as-a-Layer pattern:

vars: {
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: traces.otelTracesEndpoint,
  OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: logs.otelLogsEndpoint,
},

For a full end-to-end walkthrough — dataset, token, Worker wiring, and a monitor on top — follow Observability with Axiom.

Reference

Dataset · ApiToken · Monitor · Notifier · Dashboard · Annotation · View · VirtualField