Redis What’s Slowlog?

當命令執行超過參數值 Parameter: slowlog-log-slower-than (預設是 10ms) 時,該筆命令就會被記錄在 Slowlog中,而記錄下來的筆數是參考參數值 Parameter: slowlog-max-len (預設是 128 筆),新寫入的記錄將會覆蓋最舊的記錄,而這個資訊會存在於每一台節點上的 Redis 服務器中。所以可以透過調整這個參數來記錄更多的資訊,來進一步排查問題。

Jerry’s Notes
What’s next?
2 min readMar 23, 2022

--

Q: What’s Slowlog?

■ SLOWLOG command returns queries that exceeded a specified execution time.

■ The execution time does not include I/O operations like talking with the client, sending the reply and so forth, but just the time needed to actually execute the command. 執行時間只計算Redis server 端存取數據的時間,並不包含 client 端到 server 端(網路傳輸時間)、及其他時間。

Parameter

■ slowlog-log-slower-than: The maximum execution time, in microseconds, for commands to be logged by the Redis Slow Log feature. By default, is 10000 (microseconds), which 10 milliseconds.

■ slowlog-max-len: The maximum length of the Redis Slow Log. (Default value is 128).

[+] SLOWLOG GET — Redis:
https://redis.io/commands/slowlog-get)

$ redis-cli -h xxx
$ xxx:6379> SLOWLOG GET
1) 1) (integer) 4 # 日誌的唯一標識符(uid)
2) (integer) 1378781447 # 命令執行時的 UNIX 時間戳
3) (integer) 13 # 命令執行的時長,以微秒計算
4) 1) "SET" # 命令以及命令參數
2) "database"
3) "Redis"

Q: What’s Log Deliver on ElastiCache Redis 6.x version?

Log delivery是 ElastiCache Redis 6.x 所提供的功能,他可以將 slowlog 跟 engine log 同步至 CloudWatch Logs 或 Kinesis Data Firehose 中,來提供後續排查問題使用。

Log delivery lets you stream Redis SLOWLOG to one of two destinations:

■ Amazon Kinesis Data Firehose

■ Amazon CloudWatch Logs

--

--

Jerry’s Notes
What’s next?

An cloud support engineer focus on troubleshooting with customer reported issue ,and cloud solution architecture.