-1

I am running Redis + Sentinel as containers on 4 RHEL machines. Is there a way of finding out which Redis server was the master on a specific day?

I know running INFO (INFO REPLICATION) will give me the current role for each server, but I'd like to find out which one was the master on a specific day in order to review metrics in an APM.

Confounder
  • 469
  • 1
  • 8
  • 23

1 Answers1

2

I quickly run a setup and triggered sentinel failover to generate below logs.

If you check your sentinel log file you will find logs like this

55451:X 03 Sep 2022 20:27:02.699 # Executing user requested FAILOVER of 'mymaster'
55451:X 03 Sep 2022 20:27:02.699 # +new-epoch 1
55451:X 03 Sep 2022 20:27:02.699 # +try-failover master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.749 * Sentinel new configuration saved on disk
55451:X 03 Sep 2022 20:27:02.749 # +vote-for-leader dcfdb6ee5b4341866ac2933b8cf15f08631ac366 1
55451:X 03 Sep 2022 20:27:02.749 # +elected-leader master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.749 # +failover-state-select-slave master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.833 # +selected-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.833 * +failover-state-send-slaveof-noone slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.913 * +failover-state-wait-promotion slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.055 * Sentinel new configuration saved on disk
55451:X 03 Sep 2022 20:27:03.055 # +promoted-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.055 # +failover-state-reconf-slaves master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.144 # +failover-end master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.144 # +switch-master mymaster 127.0.0.1 6379 127.0.0.1 6380
55451:X 03 Sep 2022 20:27:03.144 * +slave slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6380
55451:X 03 Sep 2022 20:27:03.146 * Sentinel new configuration saved on disk
55451:X 03 Sep 2022 20:27:13.256 * +convert-to-slave slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6380

You can easily find when which server was promoted as master in your setup

55451:X 03 Sep 2022 20:27:03.055 # +promoted-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379

VedantK
  • 9,728
  • 7
  • 66
  • 71
  • Thanks Veke. I'm able to see "+promoted-slave" in the Sentinel logs. I have 4 instances of Sentinel running and queried the logs to find "+promoted-slave" straddling the period I'm interested in to identify the master at the time. – Confounder Sep 06 '22 at 14:39