You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a structured logging world we live in, but do we really have to look at JSON? Not with Ax.
3
+
4
+
## Installation
5
+
For now there's no pre-built binaries, so to run this you need a reasonably recent version of Go. Then either git clone this project in `$GOPATH/src/github.com/zefhemel/ax` or run `go get -u github.com/zefhemel/ax`.
6
+
7
+
To install dependencies:
8
+
9
+
make dep
10
+
11
+
To run tests:
12
+
13
+
make test
14
+
15
+
To "go install" ax (this will put the resulting binary in `$GOPATH/bin` so put that in your `$PATH`)
16
+
17
+
make
18
+
19
+
20
+
## Upgrade
21
+
22
+
In `$GOPATH/src/github.com/zefhemel/ax`:
23
+
24
+
git pull
25
+
make
26
+
27
+
## Setup
28
+
Once you have `ax` installed, the first thing you'll want to do is setup bash or zsh command completion (I'm not kidding).
29
+
30
+
For bash, add to `~/.bash_profile`:
31
+
32
+
eval "$(ax --completion-script-bash)"
33
+
34
+
For zsh, add to `~/.zshrc`:
35
+
36
+
eval "$(ax --completion-script-zsh)"
37
+
38
+
After this, you can auto complete commands, flags, environments and even attribute names with TAB. Use it, love it.
39
+
40
+
## Setup with Kibana
41
+
To setup Ax for use with Kibana, run:
42
+
43
+
ax env add
44
+
45
+
This will prompt you for a name, backend-type (kibana in this case), URL and if this URL is basic auth protected a username and password, and then an index.
46
+
47
+
To see if it works, just run:
48
+
49
+
ax --env yourenvname
50
+
51
+
Or, most likely your new env is the default (check with `ax env`) and you can just run:
52
+
53
+
ax
54
+
55
+
This should show you the (200) most recent logs.
56
+
57
+
If you're comfortable with YAML, you can run `ax env edit` which will open an editor with the `~/.config/ax/ax.yaml` file (either the editor set in your `EDITOR` env variable, with a fallback to `nano`). In there you can easily create more environments quickly.
58
+
59
+
## Use with Docker
60
+
To use Ax with docker, simply use the `--docker` flag and a container name pattern. I usually use auto complete here (which works for docker containers too):
61
+
62
+
ax --docker turbo_
63
+
64
+
To query logs for all containers with "turbo\_" in the name. This assumes you have the `docker` binary in your path and setup properly.
65
+
66
+
## Use with log files or processes
67
+
You can also pipe logs directly into Ax:
68
+
69
+
tail -f /var/log/something.log | ax
70
+
71
+
# Filtering and selecting attributes
72
+
Looking at all logs is nice, but it only gets really interesting if you can start to filter stuff and by selecting only certain attributes.
73
+
74
+
To search for all logs containing the phrase "Traceback":
75
+
76
+
ax "Traceback"
77
+
78
+
To search for all logs with the phrase "Traceback" and where the attribute "domain" is set to "zef":
79
+
80
+
ax --where domain=zef "Traceback"
81
+
82
+
Again, after running Ax once on an environment it will cache attribute names, so you get completion for those too, usually.
83
+
84
+
Ax also supports the `!=` operator:
85
+
86
+
ax --where domain!=zef
87
+
88
+
If you have a lot of extra attributes in your log messages, you can select just a few of them:
89
+
90
+
ax --where domain=zef --select message --select tag
91
+
92
+
# "Tailing" logs
93
+
Use the `-f` flag:
94
+
95
+
ax -f --where domain=zef
96
+
97
+
# Different output formats
98
+
Don't like the default textual output, perhaps you prefer YAML:
0 commit comments