datalust / seq-api

HTTP API client for Seq
https://datalust.co/seq
Apache License 2.0
77 stars 21 forks source link

List events in the CLEF format #56

Closed tompazourek closed 5 years ago

tompazourek commented 5 years ago

I'm using the InSignalAsync method to list existing events.

What I need is to get the events in the CLEF (compact JSON format) similarly to how StreamAsync returns them.

I can't find any way how to do that. Any recommendations?

Cheers.

nblumhardt commented 5 years ago

Hi Tom, thanks for the post. Just thinking back to this, there's no direct wrapper API for it, but the following should work (with appropriate parameters):

var connection = new SeqConnection("http://localhost:5341");
var events = await connection.LoadResourceGroupAsync("Events");

// Available params are: signal, filter, count, startAtId, afterId, fromDateUtc, toDateUtc, shortCircuitAfter, render, clef, permalinkId
var clef = connection.Client.GetStringAsync(events, "InSignal", new Dictionary<string, object>
{
    ["signal"] = "signal-1,signal-20",
    ["filter"] = "@Level = 'Error'",
    ["count"] = 5,
    ["clef"] = true,
});

Let me know if you have success with it!

tompazourek commented 5 years ago

Hi Nicholas,

Thank you for your help, this worked very well!

I used it in conjunction with the clef-tool to move some events between Seq instances, and I managed to accomplish what I needed.