Fetch existing data usage and storage metrics from AWS CloudWatch for your S3 buckets and display them in a card on your Laravel Pulse dashboard.
Developers at Arcana Softworks have been building business-class PHP applications for more than 10 years. Learn more about what we can do for you or your business.
You can install the package via composer:
composer require arcana/laravel-pulse-s3-metrics
You can optionally publish the config file with:
php artisan vendor:publish --tag="laravel-pulse-s3-metrics-config"
This is the contents of the published config file:
return [
'enabled' => env('PULSE_S3_METRICS_ENABLED', true),
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'class' => env('AWS_STORAGE_CLASS', 'StandardStorage'),
];
By default, this package will fetch metrics for the S3 bucket specified in your AWS_BUCKET
environment variable. You can override this by setting the bucket
config value.
One variable you may be missing is the AWS_STORAGE_CLASS
variable, which has been introduced by this package. This should be set to the storage class of your S3 bucket. The default value is StandardStorage
, which is the default storage class for S3 buckets. If you have a different storage class, you should set this variable to the appropriate value.
The region should be the region where your S3 metrics are stored on CloudWatch.
Publish the Laravel Pulse config so that you may add the S3 Metrics recorder:
php artisan vendor:publish --tag=pulse-config
This will publish the Pulse config to config/pulse.php
Add the S3 Metrics recorder to the recorders
section of the Pulse config:
'recorders' => [
// Existing recorders...
// ...
\Arcana\PulseS3Metrics\Recorders\S3Metrics::class => [
'enabled' => env('PULSE_S3_METRICS_ENABLED', true),
],
],
Publish the Laravel Pulse dashboard view:
php artisan vendor:publish --tag=pulse-dashboard
This will publish the Pulse dashboard view to resources/views/vendor/pulse/dashboard.blade.php
Add the S3 Metrics card to your dashboard (the card looks best at full width):
<x-pulse>
<livewire:pulse-s3-metrics cols="full" />
{{-- Existing cards... --}}
</x-pulse>
The S3 Metrics card may not show metrics from your S3 bucket immediately. It may take up to 24 hours for metrics to be available on CloudWatch.
The recorder will run periodically whilst php artisan pulse:work
is running. You can run this command in a terminal window to start the recorder:
php artisan pulse:check
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.