Redis Sentinel
Use Sentinel-based Redis master discovery in self-hosted deployments
By default, the Opik backends connect directly to a single Redis endpoint through REDIS_URL. Enable Redis Sentinel when you want them to discover the active Redis master and reconnect after Sentinel promotes a replica. Opik configures the clients only; you must provide and operate the Redis master, replicas, and Sentinel processes.
Configure Sentinel on both the Java backend and the Python backend, which runs the RQ workers. A service left on a fixed Redis address keeps writing to the old master after a failover: those writes are lost when Sentinel demotes it, and later ones fail with READONLY.
Prerequisites
Before enabling Sentinel mode, make sure that:
- A Redis master and at least one replica are running and synchronized.
- All Sentinel processes monitor the same master set name.
- Sentinel-announced Redis and Sentinel addresses are reachable from both backends.
- Authentication and TLS settings are consistent across the topology.
- Production deployments use at least three Sentinel processes in independent failure domains. A typical three-Sentinel deployment uses a quorum of
2.
See the Redis Sentinel documentation for Redis-side deployment and quorum guidance.
Configure the backends
The example below uses:
mymasteras the Sentinel master set namesentinel-1:26379as the initial Sentinel seedsentinel-2:26379andsentinel-3:26379as additional seedsredis-passwordfor Redis data-node authenticationsentinel-passwordfor Sentinel authentication- Redis database
0
Docker Compose
Kubernetes / Helm
Add the same overrides to both backends in deployment/docker-compose/docker-compose.override.yaml:
Apply the change from the deployment/docker-compose directory:
How REDIS_URL is interpreted
When Sentinel mode is disabled, REDIS_URL remains the direct single-node Redis URL. When Sentinel mode is enabled, the same URL is interpreted as follows:
Sentinel authentication is configured independently with OPIK_REDIS_SENTINEL_USERNAME and OPIK_REDIS_SENTINEL_PASSWORD.
For ACL-based authentication, use separate credentials for the data nodes and Sentinel:
If Sentinel does not require authentication, omit the Sentinel username and password variables.
Configuration reference
Configure these environment variables, with the same values, on both the Java backend and the Python backend. Both read them the same way, and both validate them at startup whenever Sentinel is enabled, refusing to start on an invalid value. Set to an empty value, OPIK_REDIS_SENTINEL_ENABLED means disabled and the nodes, username and password are treated as unset; any other empty variable is invalid. Set boolean variables to true or false.
Duration values accept forms such as 500ms, 5s, and 1m. Timeouts and the scan interval must be between 100ms and 5m; the backoff base and cap between 1ms and 5m.
Sentinel mode cannot be combined with AWS IAM authentication (redis.awsIamAuth). ElastiCache and MemoryDB, where IAM authentication applies, do not offer Sentinel; point REDIS_URL at their primary endpoint in single-node mode instead.
TLS
Use the rediss:// scheme in REDIS_URL and every address in OPIK_REDIS_SENTINEL_NODES when the Sentinel topology requires TLS.
Opik does not expose separate connection schemes for Sentinel and Redis data nodes, so a topology that mixes plaintext Sentinel connections with TLS data-node connections, or the reverse, is not supported by this configuration.
For TLS deployments, make sure Sentinel announces hostnames or addresses that:
- Are reachable from both backends
- Match the subject alternative names in the Redis server certificates
Production guidance
- Keep
OPIK_REDIS_SENTINEL_CHECK_SENTINELS_LIST=truein production. - Provide multiple seed addresses through
OPIK_REDIS_SENTINEL_NODESso backend startup does not depend on one Sentinel being reachable. - Place Sentinel processes in independent failure domains.
- Ensure replicas are synchronized and eligible for promotion before testing failover.
- Store Redis and Sentinel credentials in your deployment’s secret manager rather than directly in a committed values or Compose file.
- Remember that Redis replication is asynchronous. Sentinel improves availability but does not guarantee that every acknowledged write survives every failure.
Verify the configuration
Confirm Sentinel mode at startup
Check the Java backend logs for:
Docker Compose
Kubernetes / Helm
If the log reports sentinel 'false', Sentinel mode is not enabled in the Java backend process.
The Python backend logs Redis: using Sentinel master 'mymaster' through 3 sentinels, database 0 at startup.
Check Redis health
Query the backend health endpoint from inside the deployment or through a port-forward:
Docker Compose
Kubernetes / Helm
A healthy Redis topology returns HTTP 200.
The Redis health check pings the master currently discovered through Sentinel, the only node that serves Opik traffic. A lost replica or Sentinel keeps the backend ready; the check can briefly report unhealthy while Sentinel promotes a new master.
Validate failover
Perform this procedure only in a development or staging environment. Triggering a failover changes the writable Redis node and can interrupt active requests.
Keep both Opik backends running while performing this check.
The commands below use OPIK_REDIS_SENTINEL_USERNAME and OPIK_REDIS_SENTINEL_PASSWORD. Set these variables in the shell running redis-cli. If the username is unset, the commands authenticate as the Redis default ACL user.
Trigger a controlled failover
Or stop the current master according to your Redis operating procedure:
Requests may briefly fail or time out while Sentinel promotes a replica and Redisson reconnects. Tune the retry and timeout settings to match your Sentinel failure-detection and failover timing.
Troubleshooting
Useful Sentinel diagnostics: