Skip to content

Instantly share code, notes, and snippets.

@stavalfi
Created August 7, 2021 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stavalfi/285eebfc93872d7eb83e31286ae845a5 to your computer and use it in GitHub Desktop.
Save stavalfi/285eebfc93872d7eb83e31286ae845a5 to your computer and use it in GitHub Desktop.
Evaluate Redis Slowlogs output in nodejs
// 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