Send data with the Splunk HEC API
This page explains how to send data to Axiom from Splunk forwarders, the OpenTelemetry splunk_hec exporter, logging libraries, and custom clients through the Splunk HTTP Event Collector (HEC) compatible API.
Axiom offers a Splunk HTTP Event Collector (HEC) compatible API so you can send events from Splunk forwarders, the OpenTelemetry splunk_hec exporter, Splunk logging libraries, and custom HTTP clients without changing your existing tooling.
The HEC API is served from a dedicated host on your edge deployment: hec.AXIOM_DOMAIN. For example, if your edge deployment’s base domain is us-east-1.aws.edge.axiom.co, the HEC endpoint is https://hec.us-east-1.aws.edge.axiom.co.
To connect a SaaS product or security tool that offers a built-in Splunk destination, such as GitHub, Vercel, or Bitwarden, see Send data from products with a Splunk HEC destination.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to ingest data to the dataset you have created.
Authentication
Authenticate every request with an Axiom API token that has permission to ingest into the target dataset. The HEC API accepts the token in any of the following schemes:
| Scheme | Header |
|---|---|
| Splunk (default HEC clients) | Authorization: Splunk API_TOKEN |
| Bearer | Authorization: Bearer API_TOKEN |
| Basic | Authorization: Basic <base64 of x:API_TOKEN> (for example, curl -u x:API_TOKEN) |
Requests without a valid token are rejected with 401 Unauthorized (HEC code 2 when the token is missing, or 3 when the token is invalid) or 403 Forbidden (HEC code 4 when the token can’t ingest into the dataset, the dataset is shared, or the organization is suspended).
Choose the target dataset
In Splunk, events are routed by index. Axiom maps the HEC index to an Axiom dataset and resolves it in the following order:
- The
indexquery parameter, for example?index=DATASET_NAME. - The
indexfield inside the first event envelope. Axiom sends the entire request to that dataset. To split events across datasets, send separate requests. - The dataset the API token is scoped to, when the token grants ingest access to exactly one dataset.
If none of these resolve to a dataset, the request is rejected with HEC code 7 (Incorrect index).
Send events
Send JSON events to /services/collector/event. The bare /services/collector path is an alias of the event endpoint. Each request body is one or more HEC event envelopes, which may be concatenated (newline-delimited or back-to-back).
A successful ingest returns 200 OK with the Splunk status body:
Event envelope fields
Axiom interprets the standard HEC envelope fields as follows:
| Field | Behavior |
|---|---|
event | When an object, its keys become top-level fields of the Axiom event. When a string, it’s stored in the _raw field. |
fields | Merged into the event as top-level fields. |
time | Parsed as the event timestamp (_time). Accepts epoch seconds, epoch milliseconds, or an RFC 3339 string. When omitted, Axiom assigns the ingest time. |
index | Selects the target dataset (see Choose the target dataset) and is also retained as a field. |
host, source, sourcetype | Retained as fields on the event. |
Send raw events
Send arbitrary payloads to /services/collector/raw. Metadata is supplied through query parameters rather than an envelope. Each line of a text/plain body becomes an event; JSON bodies are also accepted.
Compressed payloads
The HEC API accepts gzip-compressed request bodies. Set Content-Encoding: gzip and send the gzipped payload:
Check service health
GET /services/collector/health (and the versioned /services/collector/health/1.0) report whether the collector is accepting data. No authentication is required.
Client examples
The following examples send events from Splunk logging libraries and from custom code.
Send logs from JavaScript using splunk-logging
Send logs from Python using splunk_handler
Send logs from Go using net/http
Limitations
The Axiom HEC API differs from a Splunk HEC endpoint in the following ways:
- Axiom only accepts HTTPS on port
443. Splunk’s default port8088isn’t available. Axiom redirects plain HTTP requests on port80to HTTPS, and many HTTP clients don’t resend the request body after the redirect. - Axiom doesn’t serve the versioned
/services/collector/event/1.0and/services/collector/raw/1.0paths. Requests to these paths return404. The versioned health path/services/collector/health/1.0is available. - Axiom doesn’t support indexer acknowledgment. Axiom accepts the
X-Splunk-Request-Channelheader and thechannelquery parameter, but doesn’t serve/services/collector/ack. - Axiom stores the fields inside
event, thefieldsobject, and the standard envelope fields listed in Event envelope fields. Axiom doesn’t store other top-level fields of the envelope.
Response codes
Responses follow the Splunk HEC convention: an HTTP status code plus a JSON body carrying a Splunk code.
| HTTP status | HEC code | Meaning |
|---|---|---|
200 | 0 | Success. |
200 | 17 | The collector is healthy (health endpoints only). |
400 | 5 | No data. The request body was empty. |
400 | 6 | Invalid data format. The body couldn’t be parsed, the dataset is in another edge deployment, or the dataset isn’t an events or logs dataset. |
400 | 7 | Incorrect index. The target dataset couldn’t be resolved. |
401 | 2 | Token missing. |
401 | 3 | Token invalid. |
403 | 4 | Token can’t ingest into the dataset, the dataset is shared, or the organization is suspended. |
404 | 7 | Dataset not found. |