REST /var/log
reader
Some assumptions could be considered TODO items for future enhancement
- The log files are in
/var/log
- The log files are uncompressed plain text files
- Compressed or archived files (e.g.
.gz
,bz2
,.tar
,.tgz
) are not supported
- Compressed or archived files (e.g.
- The log files are sorted by timestamp (oldest first) as it is captured in each log event
- Log events are separated by a newline character
- REST response Content-Type is text/plain; charset=utf-8, regardless of the Accept request header
- All errors are returned to REST callers as HTTP status 500, even if these might be correctable by the caller
- LRU result caching of compiled regexes and search results are not implemented
GET /api/v1/logs
- Get list of all log files in/var/log
that this service can readGET /api/v1/logs/{log}
- Get the contents of the log file specified by{log}
in/var/log
(e.g./api/v1/logs/messages
)
Query Parameters:n
- Number of lines to return (default: 25, all: 0)q
- Case sensitive fixed text filter to apply to each line (default:""
), more performant thanr
r
- Regex filter to apply to each line (default:.*
)
- Go - Programming language
- HttpRouter - HTTP request router
- The
service
package contains the logic of the service, agnostic of presentation and transport - The
controller
package contains the HTTP request handlers
Optionally, arbitrarily large fake log files can be generated in json or delimited format to augment any that
are naturally in /var/log
.
- See: GitHub mikebd/go-make-log - Generate fake application log files (e.g. as input to log processors)
docker build -t go-read-var-log .
- Build the Docker imagedocker run go-read-var-log
- Run without arguments
OR
docker run go-read-var-log /app/go-read-var-log <args>
- Run with the given arguments
go run ./main <args>
- Run the main.go file with the given arguments
Argument | Description |
---|---|
-h | --help |
Print the help message |
-lt |
Log with timestamps (UTC) |
-n |
Number of lines to return (default 25) |
-p |
HTTP Port to listen on (default 8080) |