GithubHelp home page GithubHelp logo

Comments (4)

Jacq avatar Jacq commented on June 12, 2024 1

Seems to work fine I have just changed the requirement in composer.json with no additional modifications.
There are details about the upgrade to monolog 2.0 [here](https://github.com/Seldaek/monolog/blob/master/UPGRADE but I am not familiarize with its internals.

I am using the loki handler embedded in a logger provider for Laravel 7.X and I did not notice any important issues.
The only strange behavior is that Loki live mode is not working with this stream I have to check all the others but for the moment this seems the only one not tailing new messages live mode.
Cheers,

If anyone is interested in using in laravel this is an example of the logger provider similar to this logstash example:

<?php

namespace App\Providers;

use Itspire\MonologLoki\Handler\LokiHandler;
use Monolog\Handler\WhatFailureGroupHandler;
use Monolog\Logger;
use Psr\Log\LoggerInterface;

class LokiLoggerProvider
{

    /**
     * @param array $config
     * @return LoggerInterface
     */
    public function __invoke(array $config): LoggerInterface
    {
        $options = [
            'entrypoint' => $config['url'],
            'context' => [
                // Set here your globally applicable context variables
            ],
            'labels' => [
                // Set here your globally applicable labels
                'app' => config('app.name')
            ],
            'client_name' => gethostname(), // Here set a unique identifier for the client host
        ];
        // Optional : if you're using basic auth to authentify
        if (!empty($config['user']) && !empty($config['password'])) {
            $options['auth'] = [
                'basic' => [$config['user'], $config['password']],
            ];
        }
        $handler =new WhatFailureGroupHandler(
            [
                new LokiHandler($options)
            ]);

        return new Logger('loki.main', [$handler]);
    }

}

from monolog-loki.

rrajkomar avatar rrajkomar commented on June 12, 2024

Well that's mostly because I haven't tested it with Monolog 2.0 yet.
Since the current LTS version of Symfony (4.4) has a requirement on monolog ^1.25.1 through monolog-bridge
And I only use monolog though the LTS version of Symfony,
I did not test it with ~2.0.

However, you're welcome to try it in order to check if it works.
And provide a PR if it doesn't as is.
Otherwise, I'll work on a compatible version when an LTS version of Symfony supports the 2.0 version of monolog.

from monolog-loki.

rrajkomar avatar rrajkomar commented on June 12, 2024

The only strange behavior is that Loki live mode is not working with this stream I have to check all the others but for the moment this seems the only one not tailing new messages live mode.

I had thay issue a while back and after searching a bit on the web I foudn out that it was related to my grafana configuration and that I had to add the following headers to my Loki datasource to enable WebSocket support :

Connection: Upgrade
Upgrade: Websocket

Maybe it will solve your issue.

from monolog-loki.

rrajkomar avatar rrajkomar commented on June 12, 2024

Sorry, unexpected side effect from my commit message.
Was not meant to close the Github issue.
I will adapt so this doesn't happen again.

from monolog-loki.

Related Issues (4)

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.