Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap build configuration #92

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
ted-gould marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
21 changes: 21 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
@@ -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 <<EOL > ${SNAP_DATA}/journald-config
active_deployment = "journald-backend"

[deployments]
[deployments.journald-backend]
url = "${journald_url}"
token = "${journald_token}"
EOL

cat <<EOL > ${SNAP_DATA}/journald-env
AXIOM_DATASET="${journald_dataset}"
AXIOM_DEPLOYMENT=journald-backend
EOL

snapctl restart axiom.journald-ingester
23 changes: 23 additions & 0 deletions snap/local/bin/journald-ingester
Original file line number Diff line number Diff line change
@@ -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}
40 changes: 40 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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