Grep, but for log files of various shapes and sizes
105
Grep, but for log files of various shapes and sizes
This project was created in slightly more than an evening with the intention that I'll add more log formats to it as I go along and feel like they would be useful. There's no guarantee I'll actually do that though.
Download the latest release from the releases page and add it somewhere on your path (e.g. ~/.bin/local).
Windows users will currently need to build from source using cargo build --release, sorry!
There is also a docker image available on Docker Hub
Grep, but for log files of various shapes and sizes
Usage: loggrep --format <FORMAT> <FIELD> <REGEX>
Arguments:
<FIELD>
<REGEX>
Options:
-F, --format <FORMAT>
-h, --help Print help
-V, --version Print version
For example, for filter for nginx requests from 66.249.65.159, you could do:
cat logfile.txt | loggrep remote_addr "^66.249.65.159$"
Or to filter for GET requests:
cat logfile.txt | loggrep request "^GET"
With docker:
cat logfile.txt | docker run -i jamoyjamie/loggrep:<version> request "^GET"
The default format of nginx logs. The following fields map to the nginx variables of the same name.
Fields:
remote_addrremote_userrequeststatusbody_bytes_senthttp_refereruser_agentOriginal BSD syslog format defined in RFC-3164
Fields:
prioritytimestamphostnamemessageDefault log format for Python as per the source
Fields:
levelnamenamemessageSimple format for the update-alternatives log in /var/log/alternatives.log.
Fields:
timestampmessageFormat for dpkg logs in /var/log/dpkg.log as per the man page. Note that this log format has three different forms which makes it tricky to parse. Due to internal limitations, currently some fields need to be repeated with a numeric on the end.
Fields:
timestamptypecommandstatepkginstalled_versionactionpkg_2installed_version_2available_versionfilenamedecisionContent type
Image
Digest
sha256:c5dfcc7d9…
Size
6.9 MB
Last updated
over 3 years ago
docker pull jamoyjamie/loggrep:v0.3.0