ntail is a simple CLI utility written in Node.js which reads logs from files, parses then and outputs JSON formatted data.
It is especially useful when used in Kubernetes, as a sidecar for instance, when writing logs to stdout is not possible.
ntail checks for new files matching patterns every 10 seconds.
Create a config.yaml file using config.dist.yaml sample as a base.
NODE_ENV=production CONFIG_PATH=/path/to/config.yaml npm startdocker pull clickandmortar/ntail
docker run \
-v $PWD/path/to/logs:/logs \
-v $PWD/config.yaml:/config.yaml \
-e CONFIG_PATH=/config.yaml \
clickandmortar/ntailfiles:
- pattern: "/path/to/*.log"
# Input log line sample: [2020-07-15 15:00:25] hello ntail
format: "^\\[(?<date>[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})\\] (?<message>.*)$"
# Output raw log line if regex format does not match
fallback: true- This property may be an array of regexes, output of the first one matching will be used
- Escape character (
\) needs to be escaped in the YAML config (\\)
cp config.dist.yaml config.yaml
npm install
npm run devmake build
make push- Allow adding tags in JSON output per file pattern in config
- Restart app in development mode when YAML config changes