customergauge/logstash

APM & Logging for Laravel powered by Logstash
35,214 3
Install
composer require customergauge/logstash
Latest Version:4.0.0
PHP:>=8.2
License:MIT
Last Updated:Jun 24, 2024
Links: GitHub  ·  Packagist
Maintainer: Deleu

Laravel Logstash APM 📋

This library adapts Monolog for Laravel to communicate with Logstash for logging & metrics.

Installation

composer require customergauge/logstash

Usage

Logs

In the logging.php, define a custom channel for Laravel

'http' => [
    'driver' => 'custom',
    'via' => LogstashLoggerFactory::class,
    'address' => sprintf('tcp://%s:9601', env('LOGSTASH_ADDRESS')),
    'processor' => env('LOGSTASH_PROCESSOR'),
],

This will instruct Laravel to write any log to Logstash using a TCP connection on port 9601. TCP will guarantee log delivery. Processors allow to manipulate the $record array that gets sent to Logstash as JSON. The processor attribute accept http or queue values.

Metrics

The library also allows to collect application metrics using an apm configuration inside the logging.php file.

    'apm' => [
        'enable' => env('LOGSTASH_APM_ENABLE', true),
        'address' => sprintf('udp://%s:9602', env('LOGSTASH_ADDRESS')),
    ],

For metrics, the above configuration will instruct Laravel to use an UDP conncetion as a way to fire-and-forget. Delivery is not guaranteed, but code execution is not delayed by acknowledging metric delivery.

Processors

You may configure Http and Queue processors. Processors must implement the \CustomerGauge\Logstash\Processors\HttpProcessorInterface or the \CustomerGauge\Logstash\Processors\QueueProcessorInterface. They offer the chance to modify the $record that will be streamed to Logstash by using the ProcessorInterface system provided by Monolog.

Related Packages

hpc-code/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.

16 0
terranc/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.

507 0
hhxsv5/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

704,376 3,880
daosoft/laravel-swoole

🚀 LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.

7 0
change3/laravel-s-tcp

laraverer能快速上手swoole的tcp功能

19 2