Axiom Go adapter for Logrus

This page explains how to send logs generated by the sirupsen/logrus library to Axiom.

Use the adapter of the Axiom Go SDK to send logs generated by the sirupsen/logrus library to Axiom.

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"),
    ),
)
hook, err := adapter.New(
    adapter.SetClientOptions(
        axiom.SetAPITokenConfig("xaat-your-api-token"),
        axiom.SetEdge("us-east-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

Reference

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