mtail
is implemented in Go.
You will need to install a recent Go.
Fetch, build, and install the binary directly with go get
go install github.com/google/mtail/cmd/mtail
NOTE: If you do it this way, you won't have a supported version of mtail
.
Clone the source from GitHub into your $GOPATH
. If you don't have a $GOPATH
, see the next section.
git clone https://github.com/google/mtail
cd mtail
make test install
mtail
uses a Makefile
to build the source. This ensures the generated code is up to date and that the binary is tagged with release information.
Having fetched the source, use make
from the top of the source tree. This will install all the dependencies, and then build mtail
. This assumes that your Go environment is already set up -- see above for hints on setting it up.
The resulting binary will be in $GOPATH/bin
.
The unit tests can be run with make test
, which invokes go test
. The slower race-detector tests can be run with make testrace
.
goreleaser
is used to build the binaries available for download on the Releases page. If yuo want to build your own locally, fetch goreleaser and update the config file locally if necessary.
You can still run mtail
and its programmes with Docker.
docker build -t mtail .
docker run -it --rm mtail --help
mtail
is not much use without programme files or logs to parse, you will need to mount a path containing them into the container, as is done with the -v
flag in the example below:
docker run -it --rm -v examples/linecount.mtail:/progs/linecount.mtail -v /var/log:/logs mtail -logtostderr -one_shot -progs /progs/linecount.mtail -logs /logs/messages.log
Or, via Docker Compose, e.g. this docker-compose.yml
snippet example shows with the volume:
section:
service:
mtail:
image: mtail
command:
- -logtostderr
- -one_shot
- -progs
- /progs/linecount.mtail
- -logs
- /logs/messages.log
volume:
- type: bind
source: /var/log
target: /logs
readonly: true
- type: bind
source: examples/linecount.mtail
target: /progs/linecount.mtail
Please use gofmt
to format your code before committing. Emacs' go-mode has a lovely gofmt-before-save function.
Please read the test writing section for mtail
test style guidelines.