0.2.3 • Published 5 years ago

rds-slow-log-parse v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

rds-slow-log-parse npm.io

📃 RDS Slow Log line parser

const parse = require('rds-slow-log-parse');

const payload = new Buffer(event.awslogs.data, 'base64');
const logs = JSON.parse(zlib.gunzipSync(payload).toString('ascii'));

const events = logs.map(parse); // <= ✨ Money time

Example

Record

# Time: 190227 9:46:00
# User@Host: rdsadmin[rdsadmin] @ localhost [127.0.0.1] Id: 9059049
# Query_time: 0.000202 Lock_time: 0.000077 Rows_sent: 1 Rows_examined: 1
use operations_production;
SET timestamp=1551260760;
SELECT count(*) from mysql.rds_table_status WHERE action = "reset slave" and master_host is NULL and master_port is NULL ORDER BY action_timestamp LIMIT 1;

Result

{
    user: 'rdsadmin',
    host: 'localhost',
    ip: '127.0.0.1',
    id: '9059049',
    duration: 0.000202,
    lock_wait: 0.000077,
    rows_sent: 1,
    rows_examined: 1,
    context: 'operations_production', // optional
    timestamp: 1551260760000,
    query: `SELECT count(*) from mysql.rds_table_status WHERE action = "reset slave" and master_host is NULL and master_port is NULL ORDER BY action_timestamp LIMIT 1`,
}

Related projects:

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.0

5 years ago