This module parses Apache common log format files, counts number of times a resource has been accessed and produces a csv file with the stats.
- install the module
$ npm install https://github.com/minustime/apache-clf-parser
- Setup your script
// index.js
const parser = require('apache-clf-parser');
parser.parse({
logs: 'logs',
logExtension: 'log'
});
- Run it
$ node index.js
An optional object can be passed to the parse
function with the following properties.
option | type | default | description |
---|---|---|---|
logs | string | logs | directory where logs files are located, can include gzipped files |
logExtension | string | gz | log file extension |
report | string | report.csv | name of csv file to write report to |
logSource | string | string that gets prepended to each resource line in report file | |
filterByVerb | array | [GET, POST] | array of HTTP verbs to filter by |
ignoreResource | array | array of resource paths to ignore |
Sample csv report:
Resource,Access Count
"https:/www.kennedyspacecenter.com/images/KSC-logosmall.gif",20
"https:/www.kennedyspacecenter.com/images/NASA-logosmall.gif",16
"https:/www.kennedyspacecenter.com/images/MOSAIC-logosmall.gif",15
"https:/www.kennedyspacecenter.com/images/ksclogo-medium.gif",14
"https:/www.kennedyspacecenter.com/images/USA-logosmall.gif",14
"https:/www.kennedyspacecenter.com/images/WORLD-logosmall.gif",14
"https:/www.kennedyspacecenter.com/",11
"https:/www.kennedyspacecenter.com/history/apollo/images/apollo-logo1.gif",10