Search by

minhyung / laravel-openobserve

lostland

Laravel package for OpenObserve integration - centralized log management and monitoring

Package info

github.com/overworks/laravel-openobserve

pkg:composer/minhyung/laravel-openobserve

Statistics

Installs: 18

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

0.1.0 2026-05-28 08:12 UTC

This package is auto-updated.

Last update: 2026-11-02 02:39:33 UTC


README

Tests Latest Version on Packagist Total Downloads

Laravel adapter for minhyung/openobserve, the PHP client for OpenObserve.

This package provides:

  • A configured Minhyung\OpenObserve\Client instance bound in the container
  • A custom Laravel log channel driver that ships logs through OpenObserve's Monolog handler
  • An openobserve:test Artisan command for connection checks

한국어 문서

Requirements

  • PHP 8.4.1+
  • Laravel 13.x

Upgrading from 0.1

The upcoming 0.2 release drops support for PHP 8.3 and Laravel 11/12. Upgrade PHP and Laravel before updating this package. Existing configuration, Facade access, container bindings, and logging channel setup remain compatible.

The openobserve:test command now requires confirmation that its test record was ingested. An HTTP 200 response alone is no longer sufficient; see Connection Test.

Installation

composer require minhyung/laravel-openobserve

Publish the configuration file:

php artisan vendor:publish --tag=openobserve-config

Configuration

Add OpenObserve connection details to your .env file:

OPENOBSERVE_URL=http://localhost:5080
OPENOBSERVE_ORGANIZATION=default
OPENOBSERVE_STREAM=laravel-logs
OPENOBSERVE_EMAIL=your-email@example.com
OPENOBSERVE_PASSWORD=your-password

Configuration Options

Option Env Variable Default
url OPENOBSERVE_URL http://localhost:5080
organization OPENOBSERVE_ORGANIZATION default
stream OPENOBSERVE_STREAM default
auth.email OPENOBSERVE_EMAIL -
auth.password OPENOBSERVE_PASSWORD -
timeout OPENOBSERVE_TIMEOUT 5
ssl_verify OPENOBSERVE_SSL_VERIFY true

timeout and ssl_verify are applied to the Guzzle HTTP client that the service provider builds and injects into the OpenObserve client.

Laravel Logging Channel Setup

Add the OpenObserve channel to your config/logging.php:

'channels' => [
    // ... existing channels

    'openobserve' => [
        'driver' => 'custom',
        'via' => \Minhyung\LaravelOpenObserve\Logging\OpenObserveLogger::class,
        'level' => env('LOG_LEVEL', 'debug'),
        'name' => 'openobserve',
    ],

    // Optionally include openobserve in a stack channel
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'openobserve'],
        'ignore_exceptions' => false,
    ],
],

Set the default log channel in your .env file:

LOG_CHANNEL=stack  # or 'openobserve'

Usage

Laravel Logging

Use it just like standard Laravel logging:

use Illuminate\Support\Facades\Log;

Log::info('User logged in', ['user_id' => 123]);
Log::error('An error occurred', ['error' => $exception->getMessage()]);

Direct Client Access

The container resolves a configured Minhyung\OpenObserve\Client. Use the Facade or dependency injection to access it.

use Minhyung\LaravelOpenObserve\Facades\OpenObserve;

OpenObserve::logs()->json('laravel-logs', [
    ['level' => 'info', 'message' => 'User action', 'user_id' => 123],
]);
use Minhyung\OpenObserve\Client;

class SomeController extends Controller
{
    public function __construct(private Client $openObserve)
    {
    }

    public function index()
    {
        $this->openObserve->logs()->json('laravel-logs', [
            ['level' => 'info', 'message' => 'Controller executed'],
        ]);
    }
}

See minhyung/openobserve for the full client API (search, streams, alerts, dashboards, OTLP, etc.).

Connection Test

php artisan openobserve:test

This command sends one test log to the configured stream. It exits with code 0 only when the response has code: 200 and exactly one result for that stream with successful >= 1 and failed: 0, using integer counts. This follows the OpenObserve JSON ingestion response.

Missing connection settings, authentication or transport errors, rejected records, and missing or unrecognized ingestion results return exit code 1 with a diagnostic message. Legacy or custom response formats without per-stream counts cannot confirm ingestion and also fail. Exception details and raw response bodies are not printed.

Testing

Install development dependencies, then run the tests. The standard PHPUnit configuration is discovered automatically; no configuration file needs to be copied. Tests use fixed configuration and mock HTTP clients, so no OpenObserve server or credentials are required.

composer install
composer test

Code quality commands:

composer lint       # Check formatting with Pint
composer format     # Apply formatting
composer analyse    # Analyse src with Larastan / PHPStan level 6
composer check      # Validate Composer metadata, lint, analyse, and test

CI tests Laravel 13 on the latest PHP 8.4 and 8.5 patches, plus PHP 8.4.1 with the lowest installable stable dependencies.

Security Vulnerabilities

If you discover a security vulnerability, please email urlinee@gmail.com.

License

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

Credits