Skip to content

Quick Node script to progamatically parse and extract fields from JSON logs into TSV or CSV

License

Notifications You must be signed in to change notification settings

Datahero/json-log-scan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-log-scan

Quick Node script to progamatically parse and extract fields from JSON logs into TSV or CSV

Define the fields you want (or custom accessor functions) and scan a JSON log file to extract those fields. Record filters can be defined as well.

(new LogScan({
  filename: '~/Downloads/log.json',
  from: '2015-04-24T20:55',
  until: '2015-04-24T21:57:50',
  fields: [
    'timestamp', 
    'level', 
    'message', 
    'user.nested.id',
    function(r) { return r.firstName + ' ' + r.lastName; }
  ],

  // Output into tabbed console spacing.  Comment this out to use default CSV output
  output: 'consoleTabbed', // specifies an existing key, or a function to make your own

  // True to skip status messages / summary statistics (eg if generating a straight CSV)
  quiet: true
}))
.scan();

To Run:

  1. npm install
  2. Edit exampleScan.js
  3. node exampleScan.js

About

Quick Node script to progamatically parse and extract fields from JSON logs into TSV or CSV

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published