Skip to main content
Use the adapter of the Axiom Go SDK to send logs generated by the sirupsen/logrus library to Axiom.
The Axiom Go SDK is an open-source project and welcomes your contributions. For more information, see the GitHub repository.

Prerequisites

Set up SDK

  1. Install the Axiom Go SDK and configure your environment as explained in Send data from Go app to Axiom.
  2. In your Go app, import the logrus package. It’s imported as an adapter so that it doesn’t conflict with the sirupsen/logrus package.
    import adapter "github.com/axiomhq/axiom-go/adapters/logrus"
    
Alternatively, configure the adapter using options passed to the New function:
hook, err := adapter.New(
    adapter.SetDataset("DATASET_NAME"),
)
Replace DATASET_NAME with the name of the Axiom dataset where you send your data.

Configure client

To configure the underlying client manually, choose one of the following:
import (
    "github.com/axiomhq/axiom-go/axiom"
    adapter "github.com/axiomhq/axiom-go/adapters/logrus"
)

// ...

hook, err := adapter.New(
    adapter.SetClientOptions(
        axiom.SetPersonalTokenConfig("AXIOM_TOKEN"),
    ),
)

Configure region

By default, the adapter sends data to api.axiom.co. To target a specific edge region, pass axiom.SetEdge through SetClientOptions with the edge domain that matches the region your dataset lives in:
hook, err := adapter.New(
    adapter.SetClientOptions(
        axiom.SetAPITokenConfig("xaat-your-api-token"),
        axiom.SetEdge("eu-central-1.aws.edge.axiom.co"),
    ),
)
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
Edge endpoints require an API token (xaat-), not a personal token (xapt-). Use axiom.SetAPITokenConfig when targeting an edge region. You can also set AXIOM_EDGE or AXIOM_EDGE_URL in the environment instead of axiom.SetEdge. For a full edge URL such as a proxy, use axiom.SetEdgeURL, which takes precedence over axiom.SetEdge.
The adapter uses a buffer to batch events before sending them to Axiom. Flush this buffer explicitly by calling Close. For more information, see the example in GitHub.

Reference

For a full reference of the adapter’s functions, see the Go Packages page.