diff --git a/Makefile b/Makefile index f6babce..67d974c 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ MANPAGES_DIR := man GO_TAGS := osusergo netgo static_build # GO LD FLAGS -GO_LD_FLAGS := -s -w -extldflags "-fno-PIC -static -Wl -z now -z relro" +GO_LD_FLAGS := -s -w -extldflags "-fno-PIC -static" GO_LD_FLAGS += -X github.com/axiomhq/pkg/version.release=$(RELEASE) GO_LD_FLAGS += -X github.com/axiomhq/pkg/version.revision=$(REVISION) GO_LD_FLAGS += -X github.com/axiomhq/pkg/version.buildDate=$(BUILD_DATE) diff --git a/README.md b/README.md index fa8c7c6..20a2a7c 100644 --- a/README.md +++ b/README.md @@ -84,12 +84,29 @@ docker run axiomhq/cli ### Validate installation In all cases the installation can be validated by running `axiom -v` in the -terminal: +terminal which will return the CLI version number. Example: ```shell +$ axiom -v Axiom CLI version 1.0.0 ``` +### Install using [Snap](https://snapcraft.io) + +```shell +sudo snap install axiom +``` + +To send all system logs to Axiom: + +```shell +# Allow Axiom to access system logs +sudo snap connect axiom:log-observe + +# Configure the background service +sudo snap set axiom journald-dataset=DATASET journald-url=URL journald-token=TOKEN +``` + ## Usage ```shell diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100755 index 0000000..d921691 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,21 @@ +#!/bin/sh -e + +journald_token="$(snapctl get journald-token)" +journald_url="$(snapctl get journald-url)" +journald_dataset="$(snapctl get journald-dataset)" + +cat < ${SNAP_DATA}/journald-config +active_deployment = "journald-backend" + +[deployments] + [deployments.journald-backend] + url = "${journald_url}" + token = "${journald_token}" +EOL + +cat < ${SNAP_DATA}/journald-env +AXIOM_DATASET="${journald_dataset}" +AXIOM_DEPLOYMENT=journald-backend +EOL + +snapctl restart axiom.journald-ingester diff --git a/snap/local/bin/journald-ingester b/snap/local/bin/journald-ingester new file mode 100755 index 0000000..f1cd7e9 --- /dev/null +++ b/snap/local/bin/journald-ingester @@ -0,0 +1,23 @@ +#!/bin/sh -e + +ENVFILE="${SNAP_DATA}/journald-env" +CONFFILE="${SNAP_DATA}/journald-config" + +if [ ! -f "${CONFFILE}" ] ; then + echo "Journald configuration not available" + exit 0 +fi + +if [ ! -f "${ENVFILE}" ] ; then + echo "Journald environment not available" + exit 0 +fi + +. ${ENVFILE} + +if [ -z ${AXIOM_DATASET} ]; then + echo "Configuration not complete: ${ENVFILE}" + exit 0 +fi + +exec journalctl --output=json --no-page --follow | ${SNAP}/bin/axiom ingest -C ${CONFFILE} --timestamp-field=__REALTIME_TIMESTAMP ${AXIOM_DATASET} diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..20ada64 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,40 @@ +name: axiom +base: core20 +adopt-info: axiom-cli +summary: The power of Axiom on the command line. +description: | + Axiom is a Next-Generation Data Platform + . + Axiom's coordination-free ingest, object-store based storage, and serverless querying mean that your organization's log management can be supercharged in the most efficient and affordable way. + +grade: stable +confinement: strict +compression: lzo + +parts: + axiom-cli: + plugin: go + go-channel: 1.17/stable + source: . + prime: + - -bin/gen-cli-docs + override-build: | + GOPATH=$SNAPCRAFT_PART_INSTALL/bin make install + snapcraftctl set-version `$SNAPCRAFT_PART_INSTALL/bin/axiom --version | cut -d " " -f 4` + override-prime: | + snapcraftctl prime + mkdir -p $SNAPCRAFT_PRIME/share/ + $SNAPCRAFT_PRIME/bin/axiom completion bash > $SNAPCRAFT_PRIME/share/bash_completion + snap-helpers: + plugin: dump + source: snap/local + +apps: + axiom: + plugs: [ "network" ] + command: bin/axiom + completer: share/bash_completion + journald-ingester: + plugs: [ "network", "log-observe" ] + command: bin/journald-ingester + daemon: simple