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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,26 @@ In all cases the installation can be validated by running `axiom -v` in the
terminal:

```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-observer

# 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} ${AXIOM_DATASET}
ted-gould marked this conversation as resolved.
Show resolved Hide resolved
36 changes: 36 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: axiom
base: core20
version: '0.1'
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

parts:
axiom-cli:
plugin: go
go-channel: 1.17/stable
source: .
prime:
- -bin/gen-cli-docs
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