Skip to content

A collection of customizable cards for Laravel Pulse, displaying API request metrics, for enhanced application monitoring.

License

Notifications You must be signed in to change notification settings

Kodamity/laravel-api-usage-pulse

Repository files navigation

Kodamity Logo

Requests Graph for Laravel Pulse

API usage cards for Laravel Pulse

Build Status Total Downloads Latest Stable Version License

This is package that adds API usage cards and recorders for Laravel Pulse.

Installation

You can install the package via composer:

composer require kodamity/laravel-api-usage-pulse

Recorders

Add recorders configuration inside config/pulse.php. (If you don't have this file make sure you have published the config file of Laravel Pulse using php artisan vendor:publish --tag=pulse-config)

Requests Statistics recorder

Requests Statistics recorder records the number of requests and the number of successful requests in general for all users. And it records the number of requests and the number of successful requests for each user.

return [
    // ...
    
    'recorders' => [
        // Existing recorders...
        
        \Kodamity\Libraries\ApiUsagePulse\Recorders\RequestsStatistics::class => [
            'enabled' => env('PULSE_KDM_API_USAGE_REQUESTS_STATISTICS_ENABLED', true),
            'sample_rate' => env('PULSE_KDM_API_USAGE_REQUESTS_STATISTICS_SAMPLE_RATE', 1),
            'ignore' => [
                '#^/pulse$#', // Pulse dashboard...
            ],
        ],
    ],
];

Responses Statistics recorder

Responses Statistics recorder records the average response time and the number of responses by status code group for all users.

return [
    // ...
    
    'recorders' => [
        // Existing recorders...
        
        \Kodamity\Libraries\ApiUsagePulse\Recorders\ResponsesStatistics::class => [
            'enabled' => env('PULSE_KDM_API_USAGE_RESPONSES_STATISTICS_ENABLED', true),
            'sample_rate' => env('PULSE_KDM_API_USAGE_RESPONSES_STATISTICS_SAMPLE_RATE', 1),
            'ignore' => [
                '#^/pulse$#', // Pulse dashboard...
            ],
            'records' => [
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::Informational->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::Successful->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::Redirection->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::ClientError->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::ServerError->value,
            ],
        ],  
    ],
];

Dashboards

To add the card to the Pulse dashboard, you must first publish the vendor view.

php artisan vendor:publish --tag=pulse-dashboard

Then, you can modify the dashboard.blade.php file and add the card to the dashboard.

<livewire:kodamity.pulse.api-usage.requests-summary cols="5" rows="2" />

<livewire:kodamity.pulse.api-usage.response-statuses-graph cols="7" />

<livewire:kodamity.pulse.api-usage.response-times-graph cols="7" />

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.

About

A collection of customizable cards for Laravel Pulse, displaying API request metrics, for enhanced application monitoring.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published