PHPackages                             darkton/laravel-loki - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. darkton/laravel-loki

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

darkton/laravel-loki
====================

A Laravel package for shipping logs to Grafana Loki via OTLP with Redis buffering.

0.0.2-beta(1mo ago)018↓100%MITPHPPHP ^8.2

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/darkton/laravel-loki)[ Packagist](https://packagist.org/packages/darkton/laravel-loki)[ RSS](/packages/darkton-laravel-loki/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (11)Versions (3)Used By (0)

Laravel Loki
============

[](#laravel-loki)

> ⚠️ Beta release
> The API is considered stable for testing and production use, but may change before the first stable release (v1.0.0).

A Laravel logging package that ships logs to Grafana Loki via OTLP, built on top of Monolog.

It uses Redis buffering and queued jobs to ensure safe, asynchronous delivery without impacting application performance or creating logging feedback loops.

Installation
------------

[](#installation)

You can install the package directly via Packagist using Composer:

```
composer require darkton/laravel-loki
```

After installation, you can optionally publish the configuration file (useful for customizing Grafana access, batch limits, and queues to be used):

```
php artisan vendor:publish --tag="loki-config"
```

Basic Configuration (.env)
--------------------------

[](#basic-configuration-env)

In your `.env` file, you will need to set up the following Grafana Loki credentials to be able to send logs:

```
LOKI_OTLP_ENDPOINT="https://logs-prod-...grafana.net/otlp/v1/logs"
LOKI_USERNAME="your_stack_id"
LOKI_API_KEY="your_access_token"
```

How to access / Basic Usage
---------------------------

[](#how-to-access--basic-usage)

To enable sending logs to `loki`, you must register this channel in Laravel's logging structure. In your `config/logging.php` file, add it to the `channels` array:

```
'channels' => [
    // ...

    'loki' => [
        'driver' => 'monolog',
        'handler' => \Darkton\Loki\Logging\LokiRedisHandler::class,
    ],
],
```

Now you can log normally and direct your default stack to "loki" or access the channel directly:

```
use Illuminate\Support\Facades\Log;

Log::channel('loki')->info('This log will be saved in Redis and later dispatched to Loki!');
```

### The Dispatcher (Sync Command)

[](#the-dispatcher-sync-command)

Monolog's `LokiRedisHandler` **does not** send HTTP requests immediately. Instead, it saves them in a secure Redis list (buffer).

To actually ship these logs to Grafana Loki, you need to call the sync command. It will read the buffer, split it into organized batches, and dispatch a Laravel `Job` to perform the OTLP async request:

You can call it manually:

```
php artisan loki:sync
```

Ideally, you should schedule it in your console infrastructure (`routes/console.php` or `app/Console/Kernel.php` depending on your Laravel version):

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('loki:sync')->everyMinute();
```

> **Tip**: Make sure your `queue:work` supervisors or Horizon are running on your server, as the heavy pushing is offloaded to your application's queues!

License
-------

[](#license)

This package is distributed and licensed under the terms of the [MIT license](LICENSE).

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance89

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

57d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec945439449fb13d36c2ab6559c43e6b4d98233b159df48593194fc9af79f586?d=identicon)[darkton](/maintainers/darkton)

---

Top Contributors

[![darkton](https://avatars.githubusercontent.com/u/10508244?v=4)](https://github.com/darkton "darkton (10 commits)")

---

Tags

laravelloggingredisotlpgrafanaloki

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/darkton-laravel-loki/health.svg)

```
[![Health](https://phpackages.com/badges/darkton-laravel-loki/health.svg)](https://phpackages.com/packages/darkton-laravel-loki)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M120](/packages/laravel-pulse)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
