datalust / seq-forwarder

Local collection and reliable forwarding of log data to Seq
Apache License 2.0
57 stars 15 forks source link

Error when trying to insert event #49

Closed fagnercarvalho closed 3 years ago

fagnercarvalho commented 4 years ago

When using seq-forwarder in my .NET Core app I'm getting the following exception in the self log:

2020-03-17T22:25:05.7600053Z Exception while emitting periodic batch from Serilog.Sinks.Seq.SeqSink: System.AggregateException: 
One or more errors occurred. (Received failed result BadRequest when posting events to Seq)\r\n ---> 
System.Exception: Received failed result BadRequest when posting events to Seq\r\n   
at Serilog.Sinks.Seq.SeqSink.EmitBatchAsync(IEnumerable`1 events)\r\n   
--- End of inner exception stack trace ---\r\n   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)\r\n   at System.Threading.Tasks.Task.Wait()\r\n   at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.EmitBatch(IEnumerable`1 events)\r\n   at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()

If I open Fiddler I see that this is happening for all attempts to call the /api/events/raw endpoint. This is one example:

POST http://localhost:15341/api/events/raw HTTP/1.1
Host: localhost:15341
Content-Type: application/vnd.serilog.clef; charset=utf-8
Content-Length: 140

{"@t":"2020-03-17T22:22:39.2276310Z","@mt":"Application started. Press Ctrl+C to shut down.","SourceContext":"Microsoft.Hosting.Lifetime"}

And here is the response:

HTTP/1.1 400 Bad Request
Transfer-Encoding: chunked
Content-Type: text/plain
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 17 Mar 2020 22:22:59 GMT

Invalid raw event JSON, body must contain an 'Events' array.

Any idea about what could be happening?

If I point to a Seq server directly this works correctly.

nblumhardt commented 4 years ago

Hello @fagnercarvalho - this will be caused by the application using the compact: true setting on the Seq sink. The forwarder does not support this.

Let me know if this helps!

Best regards, Nick