Closed Cellard closed 2 years ago
This is expected. The metrics show historical data. Renaming doesn't changes the data that was snapshotted.
Is there a way to completely reset metrics?
I recognize this issue is closed, but am also curious about how to reset this particular metric. Do we need to create some sort of custom command until one is provided by the framework?
Thanks
I'm also wondering the same thing. Is there some kind of command to just completely wipe the Horizon metrics that are stored in Redis?
Here's something I came up with to clear all Horizon metrics:
use Laravel\Horizon\Repositories\RedisMetricsRepository;
$redis = resolve(RedisMetricsRepository::class)->connection();
$redis->del('measured_jobs');
$redis->del('measured_queues');
$redis->del('last_snapshot_at');
foreach($redis->keys('snapshot:*') as $key) {
$redis->del(str($key)->after(config('horizon.prefix')));
}
foreach($redis->keys('metrics:*') as $key) {
$redis->del(str($key)->after(config('horizon.prefix')));
}
Here's something I came up with to clear all Horizon metrics:
use Laravel\Horizon\Repositories\RedisMetricsRepository; $redis = resolve(RedisMetricsRepository::class)->connection(); $redis->del('measured_jobs'); $redis->del('measured_queues'); $redis->del('last_snapshot_at'); foreach($redis->keys('snapshot:*') as $key) { $redis->del(str($key)->after(config('horizon.prefix'))); } foreach($redis->keys('metrics:*') as $key) { $redis->del(str($key)->after(config('horizon.prefix'))); }
@driesvints Would you consider a PR for adding this command?
@trevorgehman I think that could maybe be useful yeah. You could attempt a PR to see if Taylor also finds it useful, thanks.
Description:
Metrics is showing jobs and queues, that were already removed or renamed.
Steps To Reproduce:
Create and run a job
Rename job class and run it again
Define a queue, run a job through it
Rename queue and run a job again
In both cases old names remained in Horizon Metics panel. I hoped they will be removed after
metrics.trim_snapshots
exceeded, but they wasn't.