Created
August 7, 2021 21:59
-
-
Save stavalfi/285eebfc93872d7eb83e31286ae845a5 to your computer and use it in GitHub Desktop.
Evaluate Redis Slowlogs output in nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is just part of the code: | |
// based on iordis client in NodeJS | |
const [[error, result]] = await client.multi([['slowlog', 'get', '-1']]).exec() | |
if (error) { | |
throw error | |
} | |
const slowLogs = result as [id: number, ts: number, executionTime: number, command: string[]][] | |
const descOrder = slowLogs.sort((a, b) => b[2] - a[2]) | |
for (const slowLog of descOrder) { | |
console.log(`${slowLog[2] / 1_000_000}s - ${slowLog[3].join(' ')}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment