Code Monkey home page Code Monkey logo

serilog-sinks-fluentd's People

Contributors

borisermakof avatar e-osw avatar gshev avatar igprya avatar pzixel avatar vikkol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

serilog-sinks-fluentd's Issues

❌This lib causes memory leaks. DO NOT USE IT.

We found a serious memory leak on sending logs to the collector. As the project is dead (no PR accepted in recent years) and because of other serious issues like this, a quick fix could be:

  1. fork it
  2. fix https://github.com/borisermakof/serilog-sinks-fluentd/blob/0ca957c9156229bb1e480def9f70ec35acb8e993/src/Serilog.Sinks.Fluentd/Sinks/Fluentd/FluentdEmitter.cs to
        public static readonly SerializationContext SerializationContext
            = new SerializationContext(PackerCompatibilityOptions.PackBinaryAsRaw);

        public FluentdEmitter(Stream stream)
        {
            //actual fix is here: allow generated stuff to be GC collected
            SerializationContext.SerializerOptions.GeneratorOption = SerializationMethodGeneratorOption.CanCollect;
            SerializationContext.Serializers.Register(new OrdinaryDictionarySerializer());
            _packer = Packer.Create(stream);
        }

BTW, the serializer used there is also dead :)

I do not intend to publish a nuget package with this fix or open my fork and I recommend you to do the same. This lib has too many existing flaws. In my opinion, it has to be re-written from scratch using a different MskPack serializer to get a stable production-ready solution.

Nested properties incorrectly rendered

Due to the MessagePackSerializer<IDictionary<string, object>>, property of nested objects are incorrectly rendered on msgpack:

log.LogInformation("this is cool data: {@data}", new {a = new {b = "test"}, c = "contoso", d = new {site = "a" }});

It does not render anything.
However, when MessagePackSerializer used Dictionary<string, object> as its "T", it does correctly:
image

Also, for boolean values, it gets rendered as string and fluentd get some issues into STREAM filtering.
Can I upload a PR to fix those issues?
Also, I saw another issue telling that there are memory leaks in this library and there's another fork (#22 and https://github.com/iNiScorporation/custom-serilog-sinks-fluentd)
Can you please tell us if this project is dead? And if not, is it possible to get those fixes from the links above?

Feature request: Supporting unix socket files

Plugin works. It is good. But looks like it uses tcp socket for transfer data into fluentd.
It will be good, if it can additionally support sending data via unix socket files.
Format of sending logs it is the same (Fluentd plugins in_forward and in_unix have the same transport protocol for input records).

Skipping messages when the server is not available.

When the server(fluentd) becomes unavailable for a short time, the client does not understand that the tcp-connection is broken and continues to send messages to the void. Why don't you use connection check with SelectMode.SelectRead? Adding this check allows you to immediately know about a broken connection.

More ReadMe info will be better

Looks like it is good plugin. But more information about using this plugin and some configurational options for this plugin or fluentd application will be better (maybe some example of code).

Extra quotes

I get extra quotes in Fluentd if I write log statements with string properties:

log.Information("Got Foo: {Foo}", "Bar");

...which results in this in the FluentD json logs (note the extra quotes in "Bar"):

{"Level":"Information","mt":"Got Foo: {Foo}", "Foo": "\"Bar\""}

I confirmed that this is the behavior of this line in FluentSinkClient:

record.Add(log.Key, log.Value.ToString());

Because log.Value.ToString() produces a string that itself contains quotes.

You can see a similar issue here: serilog/serilog#936

The fix suggested there is the equivalent of:

                    if (IsString(log.Value))
                    {
                        record.Add(log.Key, ((ScalarValue)log.Value).Value);
                    }
                    else
                    {
                        record.Add(log.Key, log.Value.ToString());
                    }

I tried that out and it produced output without extra quotes.

Is the current behavior intentional, or would you accept a PR addressing this?


As an addendum--and I'm kind of new to both Serilog and Fluentd--I'd have expected the serializer to have synthesized an @l value too, a field that inlines the arguments into the message. In the example above, that would result in "Got Foo: Bar". Is that something that makes sense to support, or should some downstream piece of Fluentd handle that?

Unhandled Exception: System.Net.Sockets.SocketException: Invalid argument

I've just started looking at fluentd & was keen to try spin up a dotnet core sample that logs to fluentd.

I've setup a Elastic Search, Kibana & Fluentd stack on docker locally (https://docs.fluentd.org/v0.12/articles/docker-logging-efk-compose) and everything is working fine (forwarding docker logs from an apache container through fluentd into kibana & logstash).

I then installed Serilog.AspNetCore, Serilog.Sinks.Console & Serilog.Sinks.Fluentd.

Console logging works fine, but as soon as I try to log to Fluentd I get the following error:

Unhandled Exception: System.Net.Sockets.SocketException: Invalid argument
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.SetLingerOption(LingerOption lref)
   at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Object optionValue)
   at Serilog.Sinks.Fluentd.FluentdSink..ctor(FluentdSinkOptions options)
   at Serilog.LoggerConfigurationFluentdExtensions.Fluentd(LoggerSinkConfiguration loggerSinkConfiguration, FluentdSinkOptions option)
   at app.Program.Main(String[] args) in /Users/andy/Development/experiments/dotnet/TodoApi/Program.cs:line 19

This is what my program.cs file looks like:

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.Fluentd;

namespace app
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                .Enrich.FromLogContext()
                .WriteTo.Fluentd(new FluentdSinkOptions("0.0.0.0",24224))
                .WriteTo.Console()
                .CreateLogger();

            Log.Information("Starting web host");

            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseSerilog()
                .UseStartup<Startup>()
                .Build();
    }
}

I've tried with our without the FluentdSinkOptions, but I consistently get the error.

I'm relatively new to dotnet core, and totally new to fluentd, so I could well be missing something, but couldn't find any usage examples for the fluentd sink, and would be hugely appreciative if you could help me out.

I'm on a mac, running dotnet core 2.0, and nuget installed and referenced Serilog.Sinks.Fluentd Version 0.2.0.

Thanks so much

Doesn't work on non-windows.

Preface. I'm not a .NET developer but our devs are trying to use this library on some hosts that are .NET Core on both windows and Linux (Docker) based.. works fine on windows. same code doesn't work at all on Linux. No output is received by fluentd. Nothing is received by the fluentd server.. Even tried to send to a local listening TCP socket and nothing..

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.