arcana/laravel-pulse-s3-metrics

Fetch existing data usage and storage metrics from AWS CloudWatch for your S3 bucket and display them in your Laravel Pulse dashboard.

1.0.0 2024-01-01 19:23 UTC

README

Screenshot of the S3 Metrics Pulse card

S3 Metrics Card for Laravel Pulse

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

Screenshot of the S3 Metrics Pulse card

Hire us

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.

Installation

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.

Install the Recorder

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),
    ],
    
],

Add the card to your Laravel Pulse dashboard

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>

Usage

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

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.