Seq.Api
4.0.0
See the version list below for details.
dotnet add package Seq.Api --version 4.0.0
NuGet\Install-Package Seq.Api -Version 4.0.0
<PackageReference Include="Seq.Api" Version="4.0.0" />
paket add Seq.Api --version 4.0.0
#r "nuget: Seq.Api, 4.0.0"
// Install Seq.Api as a Cake Addin #addin nuget:?package=Seq.Api&version=4.0.0 // Install Seq.Api as a Cake Tool #tool nuget:?package=Seq.Api&version=4.0.0
Seq HTTP API Client
This library includes:
- C# representations of the entities exposed by the Seq HTTP API
- Helper classes for interacting with the API
It's useful for querying events and working with configuration data - everything you can do using the Seq web UI, you can do programmatically via the API.
If you want to write events to Seq, use one of the logging framework clients, such as Serilog.Sinks.Seq or NLog.Targets.Seq instead.
Getting started
Install from NuGet:
Install-Package Seq.Api
Create a SeqConnection
with your server URL:
var connection = new SeqConnection("http://localhost:5341");
Navigate the "resource groups" exposed as properties of the connnection
:
var installedApps = await connection.Apps.ListAsync();
To authenticate, the SeqConnection
constructor accepts an apiKey
parameter (make sure the API key permits user-level access) or, if you want to log in with personal credentials you can await connection.Users.Login(username, password)
.
For a more complete example, see the seq-tail app included in the source.
Creating entities
The Seq API provides a /template
resource for each resource group that provides a new instance of the resource with defaults populated. The API client uses this pattern when creating new entities:
var signal = await connection.Signals.TemplateAsync();
signal.Title = "Signal 123";
await connection.Signals.AddAsync(signal);
See the signal-copy app for an example of this pattern in action.
Reading events
Seq internally limits the resources a query is allowed to consume. The query methods on SeqConnection.Events
include a status with each result set - a Partial
status indicates that further results must be retrieved.
The snippet below demonstrates paging through results to retrieve the complete set.
string lastReadEventId = null;
while(true)
{
var resultSet = await connection.Events.InSignalAsync(
filter: "Environment = 'Test'",
render: true,
afterId: lastReadEventId);
foreach (var evt in resultSet.Events)
Console.WriteLine(evt.RenderedMessage);
if (resultSet.Statistics.Status != ResultSetStatus.Partial)
break;
lastReadEventId = resultSet.Statistics.LastReadEventId;
}
If the result set is expected to be small, ListAsync()
will buffer results and return a complete list:
var resultSet = await connection.Events.ListAsync(
filter: "Environment = 'Test'",
render: true,
count: 1000);
foreach (var evt in resultSet)
Console.WriteLine(evt.RenderedMessage);
All methods that retrieve events require a count
. The API client defaults this value to 30
if not specified.
Streaming events
Seq 3.4 provides live streaming of events matching a filter and/or set of signals.
var filter = "@Level = 'Error'";
using (var stream = await connection.Events.StreamAsync<JObject>(filter: filter))
using (stream.Select(jObject => LogEventReader.ReadFromJObject(jObject))
.Subscribe(evt => Log.Write(evt)))
{
await stream;
}
The Events.StreamAsync()
method returns a hot IObservable<T>
over a WebSocket. The observable will keep producing events until either it's disposed, or the server is shut down.
Seq streams the events in compact JSON format, which the Seq API client library can deserialize into JSON.NET JObjects
for consumption.
Serilog.Formatting.Compact.Reader provides the LogEventReader
class used above to turn these documents back into Serilog LogEvent
s. Having the events represented in Serilog’s object model means they can be passed back into a logging pipeline, as performed above using Log.Write()
.
Working with the basic client
The SeqApiClient
class implements the low level interactions with the API's entities and links. It's one step up from System.Net.HttpClient
- you may be able to use it in cases not supported by the high-level wrapper.
Create a SeqApiClient
with your server URL:
var client = new SeqApiClient("http://localhost:5341");
Get the root resource and use it to retrieve one or more of the resource groups:
var root = await client.GetRootAsync();
var events = await client.GetAsync<ResourceGroup>(root, "EventsResources");
(Available resource groups, like Events
, Users
and so-on, can be seen in the root document's Links
collection.)
Use the client to navigate links from entity to entity:
var matched = await client.List<EventEntity>(
events,
"Items",
new Dictionary<string, object>{{"count", 10}, {"render", true}});
foreach (var match in matched)
Console.WriteLine(matched.RenderedMessage);
Package versioning
This package does not follow the SemVer rule of major version increments for breaking changes. Instead, the package version tracks the Seq version it supports.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 9.0.1)
- Tavis.UriTemplates (>= 1.1.0)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 9.0.1)
- System.Collections.Concurrent (>= 4.0.12)
- System.Net.Http (>= 4.1.1)
- System.Net.WebSockets.Client (>= 4.0.0)
- Tavis.UriTemplates (>= 1.1.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Seq.Api:
Package | Downloads |
---|---|
Phoenix.Functionality.Logging.Extensions.Serilog.Seq
Containes helper functionality for using the Seq sink of Serilog. |
|
Seq.App.Splunk
Description |
|
InnovationNorway.FluentPulumi
Wrapper project for pulumi simplifying the creation of azure infrastructure for Innovation Norway |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Seq.Api:
Repository | Stars |
---|---|
datalust/seqcli
The Seq command-line client. Administer, log, ingest, search, from any OS.
|
Version | Downloads | Last updated |
---|---|---|
2024.3.0 | 57,430 | 5/1/2024 |
2024.3.0-dev-00241 | 87 | 4/29/2024 |
2024.3.0-dev-00239 | 290 | 4/22/2024 |
2024.3.0-dev-00237 | 107 | 4/22/2024 |
2024.3.0-dev-00235 | 101 | 4/22/2024 |
2024.2.0 | 7,284 | 3/25/2024 |
2024.2.0-dev-00232 | 97 | 4/2/2024 |
2024.2.0-dev-00228 | 94 | 3/24/2024 |
2024.1.0 | 19,439 | 1/24/2024 |
2024.1.0-dev-00223 | 89 | 1/24/2024 |
2023.4.0 | 72,632 | 8/30/2023 |
2023.4.0-dev-00213 | 128 | 8/30/2023 |
2023.3.0 | 65,155 | 7/7/2023 |
2023.3.0-dev-00208 | 128 | 7/7/2023 |
2023.2.0 | 29,297 | 5/31/2023 |
2023.2.0-dev-00204 | 129 | 5/31/2023 |
2023.1.2-dev-00212 | 126 | 8/30/2023 |
2023.1.2-dev-00201 | 2,128 | 3/8/2023 |
2023.1.0 | 108,676 | 1/20/2023 |
2023.1.0-dev-00197 | 161 | 1/20/2023 |
2022.1.1-dev-00196 | 177 | 1/16/2023 |
2022.1.1-dev-00191 | 358 | 5/16/2022 |
2022.1.0 | 152,707 | 3/15/2022 |
2022.1.0-dev-00186 | 166 | 3/15/2022 |
2022.1.0-dev-00184 | 173 | 2/24/2022 |
2021.4.0 | 63,341 | 12/14/2021 |
2021.4.0-dev-00177 | 196 | 12/13/2021 |
2021.4.0-dev-00175 | 201 | 12/13/2021 |
2021.3.1 | 60,900 | 10/25/2021 |
2021.3.1-dev-00172 | 279 | 10/22/2021 |
2021.3.0 | 3,113 | 10/12/2021 |
2021.3.0-dev-00167 | 349 | 8/26/2021 |
2021.2.1-dev-00162 | 529 | 7/13/2021 |
2021.2.0 | 77,618 | 3/17/2021 |
2021.2.0-dev-00158 | 248 | 3/17/2021 |
2021.1.0 | 5,685 | 2/5/2021 |
2021.1.0-dev-00155 | 269 | 2/5/2021 |
2020.5.0 | 45,752 | 12/24/2020 |
2020.5.0-dev-00151 | 340 | 12/24/2020 |
2020.4.0 | 18,490 | 11/12/2020 |
2020.4.0-dev-00147 | 327 | 11/12/2020 |
2020.3.0-dev-00164 | 224 | 8/25/2021 |
2020.1.1-dev-00145 | 383 | 9/1/2020 |
2020.1.1-dev-00139 | 367 | 8/31/2020 |
2020.1.1-dev-00135 | 386 | 6/23/2020 |
2020.1.0 | 76,771 | 6/23/2020 |
2020.1.0-dev-00132 | 508 | 5/15/2020 |
2020.1.0-dev-00130 | 375 | 5/5/2020 |
2020.1.0-dev-00129 | 379 | 4/22/2020 |
5.1.3-dev-00126 | 11,790 | 12/30/2019 |
5.1.2 | 42,967 | 12/9/2019 |
5.1.2-dev-00118 | 392 | 12/9/2019 |
5.1.2-dev-00116 | 419 | 12/4/2019 |
5.1.1 | 15,006 | 9/13/2019 |
5.1.1-dev-00112 | 419 | 9/13/2019 |
5.1.1-dev-00109 | 408 | 9/13/2019 |
5.1.1-dev-00106 | 394 | 9/12/2019 |
5.1.1-dev-00104 | 416 | 9/12/2019 |
5.1.1-dev-00101 | 421 | 9/12/2019 |
5.1.1-dev-00099 | 413 | 9/12/2019 |
5.1.0 | 63,761 | 3/21/2019 |
5.1.0-dev-00094 | 469 | 3/21/2019 |
5.0.0 | 7,932 | 11/5/2018 |
5.0.0-dev-00088 | 658 | 10/29/2018 |
5.0.0-dev-00086 | 638 | 10/18/2018 |
5.0.0-dev-00084 | 1,229 | 5/17/2018 |
5.0.0-dev-00082 | 935 | 4/21/2018 |
5.0.0-dev-00079 | 815 | 4/17/2018 |
4.2.3-dev-00076 | 880 | 2/19/2018 |
4.2.2 | 34,581 | 1/16/2018 |
4.2.2-dev-00072 | 886 | 1/16/2018 |
4.2.1 | 1,151 | 1/16/2018 |
4.2.1-dev-00069 | 973 | 1/16/2018 |
4.2.1-dev-00066 | 852 | 1/15/2018 |
4.2.1-dev-00064 | 858 | 1/15/2018 |
4.2.0 | 1,393 | 1/15/2018 |
4.2.0-dev-00062 | 937 | 1/15/2018 |
4.2.0-dev-00059 | 910 | 1/10/2018 |
4.2.0-dev-00057 | 907 | 12/7/2017 |
4.0.0 | 51,247 | 5/16/2017 |
4.0.0-dev-00047 | 873 | 4/28/2017 |
4.0.0-dev-00045 | 892 | 4/25/2017 |
4.0.0-dev-00042 | 874 | 4/16/2017 |
4.0.0-dev-00041 | 814 | 4/16/2017 |
3.4.3 | 26,027 | 2/7/2017 |
3.4.3-dev-00035 | 831 | 1/29/2017 |
3.4.3-dev-00033 | 832 | 1/27/2017 |
3.4.3-dev-00031 | 853 | 1/23/2017 |
3.4.2 | 2,081 | 12/14/2016 |
3.4.2-dev-00027 | 825 | 12/14/2016 |
3.4.1 | 3,095 | 11/29/2016 |
3.4.1-dev-00023 | 824 | 11/29/2016 |
3.4.1-dev-00020 | 837 | 11/18/2016 |
3.4.0 | 3,002 | 11/18/2016 |
3.4.0-dev-00017 | 847 | 11/18/2016 |
3.4.0-dev-00016 | 833 | 10/31/2016 |
3.4.0-dev-00014 | 843 | 10/28/2016 |
3.4.0-dev-00012 | 803 | 10/28/2016 |
3.4.0-dev-00010 | 833 | 10/28/2016 |
3.4.0-dev-00008 | 831 | 10/28/2016 |
3.4.0-dev-00006 | 850 | 10/27/2016 |
3.4.0-dev-00003 | 829 | 10/27/2016 |
3.3.1 | 1,808 | 8/29/2016 |
3.0.3 | 1,389 | 3/14/2016 |
2.1.38 | 1,517 | 1/17/2016 |
2.1.36 | 1,107 | 1/8/2016 |
2.1.33 | 1,176 | 12/21/2015 |
2.1.32 | 1,180 | 11/14/2015 |
2.1.31 | 1,099 | 11/14/2015 |
2.1.30 | 1,285 | 9/10/2015 |
2.1.29 | 1,173 | 9/10/2015 |
2.1.28 | 1,322 | 7/27/2015 |
2.0.27 | 1,247 | 7/27/2015 |
2.0.26 | 1,182 | 7/27/2015 |
2.0.25 | 1,168 | 7/27/2015 |
2.0.24 | 1,212 | 7/24/2015 |
2.0.23 | 1,234 | 7/24/2015 |
2.0.22 | 1,116 | 6/16/2015 |
2.0.21 | 1,104 | 6/10/2015 |
0.6.19 | 1,317 | 3/10/2015 |
0.6.18 | 1,135 | 1/20/2015 |
0.6.17 | 1,124 | 1/19/2015 |
0.6.16 | 1,439 | 12/16/2014 |
0.6.14 | 1,427 | 12/15/2014 |
0.6.13 | 1,367 | 12/15/2014 |
0.6.12 | 1,363 | 12/15/2014 |
0.6.11 | 1,380 | 12/15/2014 |
0.6.10 | 1,440 | 12/15/2014 |
0.6.9 | 1,439 | 12/13/2014 |
0.6.8 | 1,388 | 12/11/2014 |
0.1.0 | 1,536 | 12/11/2014 |