Axiom.Dataset reference
Annotation
Section titled “Annotation”Source:
src/Axiom/Annotation.ts
An Axiom annotation — a vertical marker overlaid on charts to flag a deploy, incident, feature flag flip, or any other point/range event you want correlated with telemetry.
Annotations are scoped to one or more datasets. Use a single time for
a point marker or time + endTime for a range. The type (e.g.
"deploy", "incident") groups markers visually in the UI.
Although typically created at deploy/release time (out-of-band of regular IaC), modelling them as resources makes per-environment annotation history reproducible.
Annotation: Creating an Annotation
Section titled “Annotation: Creating an Annotation”Point-in-time deploy marker
yield* Axiom.Annotation("deploy-1.2.3", { type: "deploy", title: "Release 1.2.3", description: "https://github.com/acme/app/releases/tag/v1.2.3", datasets: ["my-app-traces", "my-app-logs"], time: new Date().toISOString(), url: "https://github.com/acme/app/releases/tag/v1.2.3",});Incident time-range
yield* Axiom.Annotation("inc-2026-04-27", { type: "incident", title: "Database failover", datasets: ["my-app-traces"], time: "2026-04-27T18:05:00Z", endTime: "2026-04-27T18:32:00Z", url: "https://incident.io/incidents/abc123",});Dataset
Section titled “Dataset”Source:
src/Axiom/Dataset.ts
An Axiom dataset — the top-level container that stores events, logs,
traces, or metrics. Pick a kind up-front: it determines schema and how
the data is shown in the UI, and cannot be changed after creation
(changing it triggers a replacement, which deletes the data).
Datasets expose their edge deployment and Axiom’s OTLP/HTTP endpoints
(otelTracesEndpoint, otelLogsEndpoint, otelMetricsEndpoint) as output
attributes so you can inject them into a Worker / Lambda’s env vars for
OpenTelemetry shipping. The bearer token is not stored in resource state
— supply Authorization: Bearer <AXIOM_TOKEN> separately at runtime.
Dataset: Creating a Dataset
Section titled “Dataset: Creating a Dataset”Logs dataset with 30-day retention
const logs = yield* Axiom.Dataset("app-logs", { name: "my-app-logs", kind: "otel:logs:v1", description: "Application logs from prod workers", retentionDays: 30, useRetentionPeriod: true,});Separate datasets per OTEL signal
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" });Dataset: Shipping OTEL data
Section titled “Dataset: Shipping OTEL data”yield* Cloudflare.Worker("api", { vars: { OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: traces.otelTracesEndpoint, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: logs.otelLogsEndpoint, // Bearer token must come from a secret store, not the dataset state. OTEL_EXPORTER_OTLP_HEADERS: `Authorization=Bearer ${env.AXIOM_TOKEN},X-Axiom-Dataset=${traces.name}`, },});VirtualField
Section titled “VirtualField”Source:
src/Axiom/VirtualField.ts
An Axiom virtual field — a saved APL expression that appears as a derived column on a dataset at query time. Use these to standardise common computations (status classes, latency buckets, parsed JSON paths) so dashboards and monitors don’t have to redefine them.
Bound to a single dataset; changing the dataset triggers a replacement.
VirtualField: Creating a Virtual Field
Section titled “VirtualField: Creating a Virtual Field”HTTP status class (e.g. 200 → “2xx”)
yield* Axiom.VirtualField("status-class", { dataset: "my-app-traces", name: "status_class", description: "HTTP response class bucket", expression: 'strcat(tostring(toint(status / 100)), "xx")', type: "string",});Latency bucket in seconds
yield* Axiom.VirtualField("latency-bucket", { dataset: "my-app-traces", name: "latency_bucket_s", expression: "bin(duration_ms / 1000.0, 0.5)", type: "number", unit: "s",});