diff --git a/config/horizon.php b/config/horizon.php index 1f95f70c..ca100eed 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -107,6 +107,38 @@ 'monitored' => 10080, ], + /* + |-------------------------------------------------------------------------- + | Metrics + |-------------------------------------------------------------------------- + | + | Here you can configure how many snapshots should be kept to display in + | the metrics graph. You should use this in conjunction with the + | `horizon:snapshot` schedule to define how long of a timespan + | you want to see in the metrics. + | + */ + + 'metrics' => [ + 'trim_snapshots' => [ + 'job' => 24, + 'queue' => 24, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Theme + |-------------------------------------------------------------------------- + | + | Here you can define which theme Horizon should load. + | + | Supported: "light", "dark" + | + */ + + 'theme' => 'light', + /* |-------------------------------------------------------------------------- | Fast Termination diff --git a/resources/js/components/LineChart.vue b/resources/js/components/LineChart.vue index 281c4f88..53721ca0 100644 --- a/resources/js/components/LineChart.vue +++ b/resources/js/components/LineChart.vue @@ -62,6 +62,6 @@ diff --git a/resources/js/screens/metrics/preview.vue b/resources/js/screens/metrics/preview.vue index e7c78cf6..17cb0c06 100644 --- a/resources/js/screens/metrics/preview.vue +++ b/resources/js/screens/metrics/preview.vue @@ -57,7 +57,7 @@ prepareData(data) { return _.chain(data) .map(value => { - value.time = this.formatDate(value.time).format("hh:mmA"); + value.time = this.formatDate(value.time).format("MMM-D hh:mmA"); return value; }) @@ -86,10 +86,11 @@ label: label, data: _.map(data, attribute), lineTension: 0, - backgroundColor: 'rgba(235, 243, 249, 0.4)', - pointBackgroundColor: '#3981B4', - borderColor: '#3981B4', - borderWidth: 4, + backgroundColor: 'transparent', + pointBackgroundColor: '#fff', + pointBorderColor: '#7746ec', + borderColor: '#7746ec', + borderWidth: 2, }, ], }; diff --git a/src/Horizon.php b/src/Horizon.php index f20911fc..c6f1e16f 100644 --- a/src/Horizon.php +++ b/src/Horizon.php @@ -61,6 +61,11 @@ class Horizon 'Metrics', 'Locks', 'Processes', ]; + public function __construct() + { + static::$useDarkTheme = config('horizon.theme') === 'dark'; + } + /** * Determine if the given request can access the Horizon dashboard. * @@ -110,11 +115,12 @@ public static function use($connection) /** * Specifies that Horizon should use the dark theme. * + * @param bool $on * @return static */ - public static function night() + public static function night($on = true) { - static::$useDarkTheme = true; + static::$useDarkTheme = $on; return new static; } diff --git a/src/Repositories/RedisMetricsRepository.php b/src/Repositories/RedisMetricsRepository.php index 08a5c815..4a01ec60 100644 --- a/src/Repositories/RedisMetricsRepository.php +++ b/src/Repositories/RedisMetricsRepository.php @@ -274,7 +274,7 @@ protected function storeSnapshotForJob($job) ); $this->connection()->zremrangebyrank( - 'snapshot:'.$key, 0, -25 + 'snapshot:'.$key, 0, -abs(1 + config('horizon.metrics.trim_snapshots.job', 24)) ); } @@ -298,7 +298,7 @@ protected function storeSnapshotForQueue($queue) ); $this->connection()->zremrangebyrank( - 'snapshot:'.$key, 0, -25 + 'snapshot:'.$key, 0, -abs(1 + config('horizon.metrics.trim_snapshots.queue', 24)) ); }