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 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.
Creating a Dataset
Section titled “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" });Shipping OTEL data
Section titled “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}`, },});