Code Monkey home page Code Monkey logo

octane-exporter's Introduction

Laravel Octane Prometheus Exporter

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Export Laravel Octane metrics using this Prometheus exporter.

๐Ÿค Supporting

If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, spread some kind words about our work or sponsor our work via Patreon. ๐Ÿ“ฆ

You will sometimes get exclusive content on tips about Laravel, AWS or Kubernetes on Patreon and some early-access to projects or packages.

๐Ÿš€ Installation

You can install the package via composer:

composer require renoki-co/octane-exporter

In case you haven't published your Octane settings, do so:

php artisan octane:install

Next up, add the following Octane tables in your config/octane.php. These tables will be used to keep track of stats for the events:

return [

    'tables' => [
        'octane_exporter_requests:1' => [
            'total_count' => 'int',
            '2xx_count' => 'int',
            '3xx_count' => 'int',
            '4xx_count' => 'int',
            '5xx_count' => 'int',
        ],
        'octane_exporter_tasks:1' => [
            'total_count' => 'int',
            'active_count' => 'int',
        ],
        'octane_exporter_workers:1' => [
            'active_count' => 'int',
        ],
        'octane_exporter_ticks:1' => [
            'total_count' => 'int',
            'active_count' => 'int',
        ],

        // ...
    ],

];

The final step is to add the following listeners after the already existent ones in config/octane.php:

return [

    'listeners' => [
        WorkerStarting::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackStartedWorkers::class,
        ],

        RequestTerminated::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackTerminatedRequests::class,
        ],

        TaskReceived::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackReceivedTasks::class,
        ],

        TaskTerminated::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackTerminatedTasks::class,
        ],

        TickReceived::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackReceivedTicks::class,
        ],

        TickTerminated::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackTerminatedTicks::class,
        ],

        WorkerStopping::class => [
            // ...
            \RenokiCo\OctaneExporter\Listeners\TrackStoppedWorkers::class,
        ],
    ],

];

๐Ÿ™Œ Usage

This package is pretty straightforward. Upon installing it, it will register the route at /exporter/group/octane-metrics and you can point Prometheus towards it for scraping.

Please keep in mind that the metrics are calculated by-process. Point your Prometheus scraper to all instances that run the Octane start command.

# HELP laravel_octane_active_tasks_count Get the number of active tasks that pass through Octane.
# TYPE laravel_octane_active_tasks_count gauge
laravel_octane_active_tasks_count{remote_addr="",addr="",name=""} 0
# HELP laravel_octane_active_ticks_count Get the number of active ticks that run currently in Octane.
# TYPE laravel_octane_active_ticks_count gauge
laravel_octane_active_ticks_count{remote_addr="",addr="",name=""} 0
# HELP laravel_octane_active_workers_count Get the number of active workers for Octane.
# TYPE laravel_octane_active_workers_count gauge
laravel_octane_active_workers_count{remote_addr="",addr="",name=""} 8
# HELP laravel_octane_requests_count Get the number of requests, by status, that passed through Octane.
# TYPE laravel_octane_requests_count gauge
laravel_octane_requests_count{remote_addr="",addr="",name="",status="2xx_count"} 7
laravel_octane_requests_count{remote_addr="",addr="",name="",status="3xx_count"} 0
laravel_octane_requests_count{remote_addr="",addr="",name="",status="4xx_count"} 0
laravel_octane_requests_count{remote_addr="",addr="",name="",status="5xx_count"} 0
laravel_octane_requests_count{remote_addr="",addr="",name="",status="total_count"} 7
# HELP laravel_octane_status Check if the octane service is running. 1 = active, 0 = inactive
# TYPE laravel_octane_status gauge
laravel_octane_status{remote_addr="",addr="",name=""} 1
# HELP laravel_octane_total_tasks_count Get the number of total tasks that passed through Octane.
# TYPE laravel_octane_total_tasks_count gauge
laravel_octane_total_tasks_count{remote_addr="",addr="",name=""} 0
# HELP laravel_octane_total_ticks_count Get the number of total ticks that got through Octane. This is the equivalent of seconds passed since this server is alive.
# TYPE laravel_octane_total_ticks_count gauge
laravel_octane_total_ticks_count{remote_addr="",addr="",name=""} 1242
# HELP php_info Information about the PHP environment.
# TYPE php_info gauge
php_info{version="8.0.11"} 1

๐Ÿ› Testing

vendor/bin/phpunit

๐Ÿค Contributing

Please see CONTRIBUTING for details.

๐Ÿ”’ Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

๐ŸŽ‰ Credits

octane-exporter's People

Contributors

rennokki avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.