Run several applications on one Redis
The store keys depend on three things: the Redis database, the connection’s key prefix (REDIS_PREFIX), and METRICS_PREFIX. Processes that share all three share their metrics. Processes that differ in one of them do not.
Keep two applications apart
Section titled “Keep two applications apart”Give each application its own METRICS_PREFIX:
METRICS_PREFIX={shop-metrics}:METRICS_PREFIX={billing-metrics}:Keep the braces. They are a Redis Cluster hash tag that keeps every key of one store in one slot.
Another Redis database, or another REDIS_PREFIX, also keeps them apart:
REDIS_METRICS_DB=3REDIS_METRICS_DB here is the variable of your own metrics connection in config/database.php. See Set up for production.
Make the parts of one application share
Section titled “Make the parts of one application share”Web servers, queue workers and the scheduler of one application must write to one store. Give them the same:
- Redis server and database (
METRICS_REDIS_CONNECTIONand its settings); REDIS_PREFIX, if the connection sets one;METRICS_PREFIX.
This matters when the parts run from separate deployments or containers, each with its own .env.
Check where a process writes
Section titled “Check where a process writes”Print the settings a process uses:
php artisan tinker --execute="dump(config('metrics.store'), config('database.redis.options.prefix'))"Run it with the environment of each part and compare.
Change the prefix of a running application
Section titled “Change the prefix of a running application”A new prefix starts an empty store. Backends read this as a counter reset. The old keys stay in Redis until you delete them.