Log analysis with map
In this recipe, we will use map
to analyze the access log for the Apache web server. The log contains access parameters for each host accessing the web server per line. The log looks like this:
64.242.88.10 - - [07/Mar/2004:16:10:02 -0800] "GET /mailman/listinfo/hsdivision HTTP/1.1" 200 6291 64.242.88.10 - - [07/Mar/2004:16:11:58 -0800] "GET /twiki/bin/view/TWiki/WikiSyntax HTTP/1.1" 200 7352 64.242.88.10 - - [07/Mar/2004:16:20:55 -0800] "GET /twiki/bin/view/Main/DCCAndPostFix HTTP/1.1" 200 5253
The line starts with hostname
or IP
that is accessing the web server. The remaining part of the line includes date and time, method of access (GET
, PUT
, POST
, and so on), and the path of the web server being accessed. The server also prints status information.
How to do it...
- Create a new project
log-parser
with thesimple
Stack template:
stack new log-parser simple
- Open
log-parser.cabal
and add the librarycontainers
as a dependent library...