From 9f9057a9ac6447793dd4251b3e93043ba857d50e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2021 15:13:09 +0000 Subject: [PATCH 01/13] Bootstrap Axiom build --- snap/snapcraft.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 snap/snapcraft.yaml diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..efd6649 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,22 @@ +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: . + +apps: + axiom: + plugs: [ "network" ] + command: bin/axiom From 0ef97e771e330878a59e9b027a2c5cf9e642b5aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2021 15:44:35 +0000 Subject: [PATCH 02/13] Drop the cli docs tool --- snap/snapcraft.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index efd6649..93c3039 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -15,6 +15,8 @@ parts: plugin: go go-channel: 1.17/stable source: . + prime: + - -bin/gen-cli-docs apps: axiom: From aa8f790219639b5bcf10d8e2c06ba327d95f6f41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2021 16:45:52 +0000 Subject: [PATCH 03/13] Add a journald ingester service --- snap/hooks/configure | 13 +++++++++++++ snap/local/bin/journald-ingester | 17 +++++++++++++++++ snap/snapcraft.yaml | 7 +++++++ 3 files changed, 37 insertions(+) create mode 100755 snap/hooks/configure create mode 100755 snap/local/bin/journald-ingester diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100755 index 0000000..d0bd5a1 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,13 @@ +#!/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-env +AXIOM_URL="${journald_url}" +AXIOM_TOKEN="${journald_token}" +AXIOM_DATASET="${journald_dataset}" +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..f98eda5 --- /dev/null +++ b/snap/local/bin/journald-ingester @@ -0,0 +1,17 @@ +#!/bin/sh -e + +ENVFILE="${SNAP_DATA}/journald-env" + +if [ ! -f "${ENVFILE}" ] ; then + echo "Journald configuration not available" + exit 0 +fi + +. ${ENVFILE} + +if [ -z ${AXIOM_URL} -o -z ${AXIOM_TOKEN} -o -z ${AXIOM_DATASET} ]; then + echo "Configuration not complete: ${ENVFILE}" + exit 0 +fi + +exec journalctl --output=json --no-page --follow | ${SNAP}/bin/axiom ingest ${AXIOM_DATASET} diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 93c3039..03d944d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -17,8 +17,15 @@ parts: source: . prime: - -bin/gen-cli-docs + snap-helpers: + plugin: dump + source: snap/local apps: axiom: plugs: [ "network" ] command: bin/axiom + journald-ingester: + plugs: [ "network", "log-observe" ] + command: bin/journald-ingester + daemon: simple From 249b7d41d5cf488468a6dd9a66e13cf93d11fd24 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2021 18:16:43 +0000 Subject: [PATCH 04/13] Add in bash completion --- snap/snapcraft.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 03d944d..62819aa 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -17,6 +17,10 @@ parts: 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 @@ -25,6 +29,7 @@ apps: axiom: plugs: [ "network" ] command: bin/axiom + completer: share/bash_completion journald-ingester: plugs: [ "network", "log-observe" ] command: bin/journald-ingester From 1513d65cff40b75e22461c39534a3d579e60aab3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2021 19:11:42 +0000 Subject: [PATCH 05/13] Reconfigure to build a TOML file --- snap/hooks/configure | 12 ++++++++++-- snap/local/bin/journald-ingester | 12 +++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index d0bd5a1..d921691 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -4,10 +4,18 @@ 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_URL="${journald_url}" -AXIOM_TOKEN="${journald_token}" 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 index f98eda5..e941de1 100755 --- a/snap/local/bin/journald-ingester +++ b/snap/local/bin/journald-ingester @@ -1,17 +1,23 @@ #!/bin/sh -e ENVFILE="${SNAP_DATA}/journald-env" +CONFFILE="${SNAP_DATA}/journald-config" -if [ ! -f "${ENVFILE}" ] ; then +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_URL} -o -z ${AXIOM_TOKEN} -o -z ${AXIOM_DATASET} ]; then +if [ -z ${AXIOM_DATASET} ]; then echo "Configuration not complete: ${ENVFILE}" exit 0 fi -exec journalctl --output=json --no-page --follow | ${SNAP}/bin/axiom ingest ${AXIOM_DATASET} +exec journalctl --output=json --no-page --follow | ${SNAP}/bin/axiom ingest -C ${CONFFILE} ${AXIOM_DATASET} From 27cb24bffa7137c2006bca7b80365d80ce5de382 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2021 19:16:00 +0000 Subject: [PATCH 06/13] Readme for snap --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 7b8564c..b669417 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,26 @@ In all cases the installation can be validated by running `axiom -v` in the terminal: ```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-observer + +# Configure the background service +sudo snap set axiom journald-dataset=DATASET journald-url=URL journald-token=TOKEN +``` + ## Usage ```shell From 5dc0f7e49c62f981f97967d07964d2f5034c30dc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 29 Oct 2021 16:44:02 +0000 Subject: [PATCH 07/13] Specify timestamp field --- snap/local/bin/journald-ingester | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/local/bin/journald-ingester b/snap/local/bin/journald-ingester index e941de1..f1cd7e9 100755 --- a/snap/local/bin/journald-ingester +++ b/snap/local/bin/journald-ingester @@ -20,4 +20,4 @@ if [ -z ${AXIOM_DATASET} ]; then exit 0 fi -exec journalctl --output=json --no-page --follow | ${SNAP}/bin/axiom ingest -C ${CONFFILE} ${AXIOM_DATASET} +exec journalctl --output=json --no-page --follow | ${SNAP}/bin/axiom ingest -C ${CONFFILE} --timestamp-field=__REALTIME_TIMESTAMP ${AXIOM_DATASET} From 86a5408e062d8eb79326dea105e8e4d45d6b8167 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 29 Oct 2021 16:47:23 +0000 Subject: [PATCH 08/13] Make the README a little clearer. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b669417..ef463f2 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ 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 From be6f29e6d939e8e74bf11d16a5f48669426987f4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Mar 2022 15:20:34 +0000 Subject: [PATCH 09/13] Switch build step to use 'make install' --- snap/snapcraft.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 62819aa..81dec2d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -9,14 +9,18 @@ description: | grade: stable confinement: strict +compression: lzo parts: axiom-cli: plugin: go - go-channel: 1.17/stable + go-channel: 1.18/stable source: . prime: - -bin/gen-cli-docs + override-build: | + export GOPATH=$SNAPCRAFT_PRIME/bin + make install override-prime: | snapcraftctl prime mkdir -p $SNAPCRAFT_PRIME/share/ From 942b305cca3ea5c9c824828f9f40c8f8f6f2801e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Mar 2022 16:13:04 +0000 Subject: [PATCH 10/13] Get the version information from the axiom binary --- snap/snapcraft.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 81dec2d..27340ed 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: axiom base: core20 -version: '0.1' +adopt-info: axiom-cli summary: The power of Axiom on the command line. description: | Axiom is a Next-Generation Data Platform @@ -19,8 +19,8 @@ parts: prime: - -bin/gen-cli-docs override-build: | - export GOPATH=$SNAPCRAFT_PRIME/bin - make install + 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/ From 222988af76d259db62d3a1b6ff78f04b8e66237d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Mar 2022 16:21:54 +0000 Subject: [PATCH 11/13] Too aggressive, 1.18 isn't on stable yet --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 27340ed..20ada64 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -14,7 +14,7 @@ compression: lzo parts: axiom-cli: plugin: go - go-channel: 1.18/stable + go-channel: 1.17/stable source: . prime: - -bin/gen-cli-docs From 51a7b861c914a67c205f1a35659f07469a112d6e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Mar 2022 21:00:29 +0000 Subject: [PATCH 12/13] Typos in instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76ad2d1..20a2a7c 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ To send all system logs to Axiom: ```shell # Allow Axiom to access system logs -sudo snap connect axiom log-observer +sudo snap connect axiom:log-observe # Configure the background service sudo snap set axiom journald-dataset=DATASET journald-url=URL journald-token=TOKEN From 9dcb87b2520164a9eacd2e2975119e3be67d35ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Mar 2022 21:19:47 +0000 Subject: [PATCH 13/13] Dropping some linker options to see if they clean up our builds --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)