1.0.12 • Published 8 years ago

plpr v1.0.12

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

pspl

PostgreSQL query log parser.

Install

$ npm install --save plpr

Usage

'use strict';
const plpr = require('plpr');

const logLineFormat = "[%m] %h:%d ";
const logLine = `[2007-09-01 16:44:49.244 UTC] 192.168.2.10:ossecdb LOG:  duration: 4.550 ms  statement: SELECT id FROM location WHERE name = 'enigma->/var/log/messages' AND server_id = '1'`;

console.log(plpr(logLine, logLineFormat));
/*
[ { starttime: '2007-09-02T01:44:49+09:00',
    endtime: '2007-09-02T01:44:49+09:00',
    host: '192.168.2.10',
    dbname: 'ossecdb',
    duration: 4.55,
    query: 'SELECT id FROM location WHERE name = \'enigma->/var/log/messages\' AND server_id = \'1\'' } ]
*/

Support PostgreSQL log format

Object Key (value type)Descriptionlog_line_prefix escape
user (string)User name%u
dbname (string)Database name%d
hostport (string)Remote IP address and remote port%r
host (string)Remote IP address%h
pid (number)Process ID%p
starttime (string)Timestamp of query start (subtract query end time from duration)%t, %m
endtime (string)Timestamp of query end%t, %m
duration (float)Duration executing query (milliseconds)(AUTO)
query (string)Query(AUTO)

Please check your PostgreSQL cofig log_line_prefix .

License

MIT © munisystem

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago