Docs
DocumentationQuery ReferenceAPI Reference
Open Console→→
DocumentationQuery ReferenceAPI Reference

Platform overview

What is Axiom?QuickstartArchitectureFeatures
Fundamentals
Datasets
Edge deployments
Limits
Performance
Optimize usage
Requirements
Semantic conventions
Glossary
Tour
SecurityRoadmap

Send data

Reference architecturesMethods

Understand data

Console
Query
Builder
Editor
Query results
Visualize
Traces
Metrics
Correlations
Save queries
Stream
Dashboard
Create
Elements
Create
Configure
Element types
Gauge
Heatmap
Log stream
Monitor list
Note
Pie chart
Scatter plot
Statistic
Table
Time series
Sections
Configure
Filter
Annotate
Monitor
Overview
View status
Configure
Examples
Monitor types
Anomaly
Match
Threshold
Alerting
Overview
Configure
Notifier types
Custom Webhook
Discord
Email
Microsoft Teams
Opsgenie
PagerDuty
Slack
Manage
Datasets
Overview
Views
Virtual fields
Access
RBAC
Tokens
CLI
Organization
Audit log
Settings
Usage and billing
Profile
Extend
Overview
AWS Lambda
AWS PrivateLink
Cloudflare Workers
Cloudflare Logpush
Convex
Grafana
Hex
Netlify
Supabase
Tailscale
Terraform
Vercel
Intelligence
Overview
Spotlight
AI agents
Overview
MCP Server
Query cost limits
Agent-created orgs
Skills
Overview
Axiom alerting
Build dashboards
Control costs
Query metrics
SRE
Translate SPL to APL
Splunk
Overview
Splunk app
Install and configure
Commands
Examples
Splunk Portal
How it works
Set up standard mode
Set up transparent mode
Observability Cloud
SPL command support
Examples
Monitor and troubleshoot

Use cases

ObservabilityProduct analytics
LLM observability
Overview
Use Axiom AI SDK
Manual instrumentation
GenAI attributes
Redaction policies

Miscellaneous

LLMs
Overview
List of docs pages
Full docs
Query reference
FAQs
Legal
Acceptable use policy
Cookies
Data processing
HIPAA
Partner agreement
Partner program guide
Privacy policy
SLA
Terms of service
Terms of use

Send data from Go app to Axiom

This page explains how to send data from a Go app to Axiom.

To send data from a Go app to Axiom, use the Axiom Go SDK.

Info

The Axiom Go SDK is an open-source project and welcomes your contributions. For more information, see the GitHub repository.

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.

Install SDK

To install the SDK, run the following:

shell
go get github.com/axiomhq/axiom-go/axiom

Import the package:

go
import "github.com/axiomhq/axiom-go/axiom"

If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables. Otherwise, create an API token and export it as AXIOM_TOKEN.

Alternatively, configure the client using options passed to the axiom.NewClient function:

go
client, err := axiom.NewClient(
    axiom.SetPersonalTokenConfig("AXIOM_TOKEN"),
)

Use client

Create and use a client in the following way:

go
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/axiomhq/axiom-go/axiom"
    "github.com/axiomhq/axiom-go/axiom/ingest"
)

func main() {
    ctx := context.Background()

    client, err := axiom.NewClient()
    if err != nil {
        log.Fatal(err)
    }

    if _, err = client.IngestEvents(ctx, "my-dataset", []axiom.Event{
        {ingest.TimestampField: time.Now(), "foo": "bar"},
        {ingest.TimestampField: time.Now(), "bar": "foo"},
    }); err != nil {
        log.Fatal(err)
    }

    res, err := client.Query(ctx, "['my-dataset'] | where foo == 'bar' | limit 100")
    if err != nil {
        log.Fatal(err)
    } else if res.Status.RowsMatched == 0 {
        log.Fatal("No matches found")
    }

    rows := res.Tables[0].Rows()
    if err := rows.Range(ctx, func(_ context.Context, row query.Row) error {
        _, err := fmt.Println(row)
        return err
    }); err != nil {
        log.Fatal(err)
    }
}

For more examples, see the examples in GitHub.

Configure region

By default, the client sends data to api.axiom.co. To target a specific edge region, pass the SetEdge option with the edge domain that matches the region your dataset lives in:

go
client, err := axiom.NewClient(
    axiom.SetEdge("eu-central-1.aws.edge.axiom.co"),
)
go
client, err := axiom.NewClient(
    axiom.SetEdge("us-east-1.aws.edge.axiom.co"),
)

This relies on AXIOM_TOKEN being set in your environment. To set the token in code as well, add axiom.SetToken("xaat-...").

The following edge domains are available:

Edge deploymentBase domain for ingest and query
US East 1 (AWS)us-east-1.aws.edge.axiom.co
EU Central 1 (AWS)eu-central-1.aws.edge.axiom.co

For more information about edge deployments, see Edge deployments.

You can also configure the region without changing code by exporting environment variables:

shell
export AXIOM_EDGE="eu-central-1.aws.edge.axiom.co"
# or, for a full URL (takes precedence over AXIOM_EDGE):
export AXIOM_EDGE_URL="https://eu-central-1.aws.edge.axiom.co"

To point at a custom edge endpoint such as a proxy or load balancer, use axiom.SetEdgeURL("https://your-edge-host"). SetEdgeURL takes precedence over SetEdge if both are set.

Info

Edge endpoints require an API token (xaat-), not a personal token (xapt-). Ingest and query calls with a personal token against an edge endpoint return personal tokens are not supported for edge operations, use an API token (xaat-).

Adapters

To use a logging package, see the following adapters:

  • Apex
  • Logrus
  • Zap
Was this page helpful?
Suggest edits on GitHub
On this page
Install SDKUse clientConfigure regionAdapters