Complete the command to check the replication offset on a Redis slave.
redis-cli info replication | grep [1]The slave_repl_offset shows the replication offset on the slave, which helps monitor replication lag.
Complete the command to check the replication lag in seconds using Redis latency info.
redis-cli latency latest | grep [1]The replication-delay latency event shows the delay in seconds between master and slave.
Fix the error in the command to monitor replication lag by comparing master and slave offsets.
master_offset=$(redis-cli info replication | grep [1] | cut -d':' -f2) slave_offset=$(redis-cli info replication | grep slave_repl_offset | cut -d':' -f2) lag=$((master_offset - slave_offset)) echo $lag
The master offset must be fetched using master_repl_offset to calculate lag correctly.
Fill both blanks to create a Redis command that shows replication lag in bytes and seconds.
redis-cli info replication | grep [1] redis-cli latency latest | grep [2]
The master_repl_offset shows lag in bytes, and replication-delay shows lag in seconds.
Fill all three blanks to create a script snippet that calculates replication lag in bytes and prints a warning if lag exceeds threshold.
master_offset=$(redis-cli info replication | grep [1] | cut -d':' -f2) slave_offset=$(redis-cli info replication | grep [2] | cut -d':' -f2) lag=$((master_offset - slave_offset)) if [ $lag -gt [3] ]; then echo "Warning: Replication lag is high: $lag bytes" fi
The script compares master_repl_offset and slave_repl_offset to find lag in bytes and warns if lag is greater than 1000 bytes.