Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Generated_Code/
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
/Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This library includes:

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 _Seq.Client.Slab_ instead.
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

Expand Down Expand Up @@ -136,3 +136,7 @@ var matched = await client.List<EventEntity>(
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.
64 changes: 0 additions & 64 deletions src/Seq.Api/Api/ResourceGroups/DataResourceGroup.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SeqApiClient : IDisposable
// Future versions of Seq may not completely support v1 features, however
// providing this as an Accept header will ensure what compatibility is available
// can be utilised.
const string SeqApiV4MediaType = "application/vnd.continuousit.seq.v4+json";
const string SeqApiV5MediaType = "application/vnd.datalust.seq.v5+json";

readonly HttpClient _httpClient;
readonly CookieContainer _cookies = new CookieContainer();
Expand Down Expand Up @@ -170,7 +170,7 @@ async Task<Stream> HttpSendAsync(HttpRequestMessage request)
if (_apiKey != null)
request.Headers.Add("X-Seq-ApiKey", _apiKey);

request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV4MediaType));
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV5MediaType));

var response = await _httpClient.SendAsync(request).ConfigureAwait(false);
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.AppInstances
{
Expand All @@ -8,19 +9,25 @@ public class AppInstanceEntity : Entity
public AppInstanceEntity()
{
Settings = new Dictionary<string, string>();
SignalIds = new List<string>();
EventsPerSuppressionWindow = 1;
#pragma warning disable 618
SignalIds = new List<string>();
#pragma warning restore 618
}

public string Title { get; set; }
public bool IsManualInputOnly { get; set; }
public string AppId { get; set; }
public Dictionary<string, string> Settings { get; set; }
public TimeSpan? ArrivalWindow { get; set; }
public List<string> SignalIds { get; set; }
public SignalExpressionPart InputSignalExpression { get; set; }
public bool DisallowManualInput { get; set; }
public int ChannelCapacity { get; set; }
public TimeSpan SuppressionTime { get; set; }
public int EventsPerSuppressionWindow { get; set; }
public int? ProcessedEventsPerMinute { get; set; }

[Obsolete("Replaced by InputSignalExpression.")]
public List<string> SignalIds { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ public ServerMetricsEntity()
RunningTasks = new List<RunningTaskPart>();
}

public double EventStoreDaysRecorded { get; set; }
public double EventStoreDaysCached { get; set; }
public int EventStoreEventsCached { get; set; }
public DateTime? EventStoreFirstSegmentDateUtc { get; set; }
public DateTime? EventStoreLastSegmentDateUtc { get; set; }
public DateTime? EventStoreFirstExtentRangeStartUtc { get; set; }
public DateTime? EventStoreLastExtentRangeEndUtc { get; set; }
public long EventStoreDiskRemainingBytes { get; set; }

public int EndpointArrivalsPerMinute { get; set; }
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/Seq.Api/Model/Events/DeleteResultPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Seq.Api.Model.Events
{
public class DeleteResultPart
{
public long DeletedEventCount { get; set; }
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class LicenseEntity : Entity
public bool IsSingleUser { get; set; }
public string StatusDescription { get; set; }
public bool IsWarning { get; set; }
public bool CanRenewOnlineNow { get; set; }
}
}
File renamed without changes.
8 changes: 8 additions & 0 deletions src/Seq.Api/Model/Monitoring/ChartDisplayStylePart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Seq.Api.Model.Monitoring
{
public class ChartDisplayStylePart
{
public int WidthColumns { get; set; } = 6;
public int HeightRows { get; set; } = 1;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System.Collections.Generic;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.Monitoring
{
public class ChartPart
{
public string Id { get; set; }

public string Title { get; set; }

public List<string> SignalIds { get; set; } = new List<string>();

public SignalExpressionPart SignalExpression { get; set; }
public List<ChartQueryPart> Queries { get; set; } = new List<ChartQueryPart>();
public ChartDisplayStylePart DisplayStyle { get; set; } = new ChartDisplayStylePart();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.Monitoring
{
Expand All @@ -7,9 +8,9 @@ public class ChartQueryPart
public string Id { get; set; }
public List<MeasurementPart> Measurements { get; set; } = new List<MeasurementPart>();
public string Where { get; set; }
public List<string> SignalIds { get; set; } = new List<string>();
public SignalExpressionPart SignalExpression { get; set; }
public List<string> GroupBy { get; set; } = new List<string>();
public MeasurementDisplayStylePart DisplayStyle = new MeasurementDisplayStylePart();
public MeasurementDisplayStylePart DisplayStyle { get; set; } = new MeasurementDisplayStylePart();
public List<AlertPart> Alerts { get; set; } = new List<AlertPart>();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.Monitoring
{
Expand All @@ -8,7 +9,7 @@ public class DashboardEntity : Entity

public string Title { get; set; }

public List<string> SignalIds { get; set; } = new List<string>();
public SignalExpressionPart SignalExpression { get; set; }

public List<ChartPart> Charts { get; set; } = new List<ChartPart>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum MeasurementDisplayPalette
Default,
Reds,
Greens,
Blues
Blues,
OrangePurple
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum MeasurementDisplayType
{
Line,
Bar,
Point
Point,
Value
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.Retention
{
public class RetentionPolicyEntity : Entity
{
public TimeSpan RetentionTime { get; set; }

public SignalExpressionPart RemovedSignalExpression { get; set; }

[Obsolete("Replaced by RemovedSignalExpression.")]
public string SignalId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Seq.Api.Model.Settings
{
public class SettingEntity : Seq.Api.Model.Entity
public class SettingEntity : Entity
{
public string Name { get; set; }
public object Value { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ public SignalEntity()
public bool IsWatched { get; set; }

public bool IsRestricted { get; set; }

public SignalGrouping Grouping { get; set; }

public string ExplicitGroupName { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/Seq.Api/Model/Signals/SignalExpressionKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Seq.Api.Model.Signals
{
public enum SignalExpressionKind
{
None,
Signal,
Intersection,
Union
}
}
90 changes: 90 additions & 0 deletions src/Seq.Api/Model/Signals/SignalExpressionPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace Seq.Api.Model.Signals
{
public class SignalExpressionPart
{
public SignalExpressionKind Kind { get; set; }

// SignalExpressionKind.Signal

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string SignalId { get; set; }

// SignalExpressionKind.Intersection, SignalExpressionKind.Union

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public SignalExpressionPart Left { get; set; }

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public SignalExpressionPart Right { get; set; }

public static SignalExpressionPart Signal(string signalId)
{
if (signalId == null) throw new ArgumentNullException(nameof(signalId));
return new SignalExpressionPart {Kind = SignalExpressionKind.Signal, SignalId = signalId};
}

public static SignalExpressionPart Intersection(SignalExpressionPart left, SignalExpressionPart right)
{
if (left == null) throw new ArgumentNullException(nameof(left));
if (right == null) throw new ArgumentNullException(nameof(right));

return new SignalExpressionPart
{
Kind = SignalExpressionKind.Intersection,
Left = left,
Right = right
};
}

public static SignalExpressionPart Union(SignalExpressionPart left, SignalExpressionPart right)
{
if (left == null) throw new ArgumentNullException(nameof(left));
if (right == null) throw new ArgumentNullException(nameof(right));

return new SignalExpressionPart
{
Kind = SignalExpressionKind.Union,
Left = left,
Right = right
};
}

public static SignalExpressionPart FromIntersectedIds(IEnumerable<string> intersectIds)
{
if (intersectIds == null) throw new ArgumentNullException(nameof(intersectIds));

if (!intersectIds.Any())
return null;

var first = Signal(intersectIds.First());
return intersectIds.Skip(1).Aggregate(first, (lhs, rhs) => Intersection(lhs, Signal(rhs)));
}

public override string ToString()
{
if (Kind == SignalExpressionKind.Signal)
return SignalId;

if (Kind == SignalExpressionKind.Intersection)
return $"{Group(Left)},{Group(Right)}";

if (Kind == SignalExpressionKind.Union)
return $"{Group(Left)}+{Group(Right)}";

throw new InvalidOperationException("Invalid signal expression kind.");
}

static string Group(SignalExpressionPart signalExpression)
{
if (signalExpression.Kind == SignalExpressionKind.Signal)
return signalExpression.ToString();

return $"({signalExpression})";
}
}
}
9 changes: 9 additions & 0 deletions src/Seq.Api/Model/Signals/SignalGrouping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Seq.Api.Model.Signals
{
public enum SignalGrouping
{
Inferred,
Explicit,
None
}
}
Loading