Skip to content

Commit

Permalink
Merge pull request #139 from datalust/dev
Browse files Browse the repository at this point in the history
2024.3.0 Release
  • Loading branch information
KodrAus authored May 1, 2024
2 parents 85d9acd + 4c650b2 commit 78b71d9
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 9 deletions.
4 changes: 2 additions & 2 deletions example/SeqEnableAAD/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static async Task Run(string server, string? username, string? tenantId, string?
var tid = await connection.Settings.FindNamedAsync(SettingName.EntraIDTenantId);

user.Username = username;
provider.Value = "Azure Active Directory";
provider.Value = "Microsoft Entra ID";
cid.Value = clientId;
ckey.Value = clientKey;
tid.Value = tenantId;
Expand All @@ -77,4 +77,4 @@ static async Task Run(string server, string? username, string? tenantId, string?
var iae = await connection.Settings.FindNamedAsync(SettingName.IsAuthenticationEnabled);
iae.Value = true;
await connection.Settings.UpdateAsync(iae); // this update needs to happen last, as enabling auth will lock this connection out
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
// limitations under the License.

using System;
using System.Collections.Generic;

namespace Seq.Api.Model.Diagnostics
{
/// <summary>
/// Metrics describing the state and performance of the Seq server.
/// </summary>
public class ServerMetricsEntity : Entity
/// <remarks>This information is not preserved across server restarts or fail-over.</remarks>
public class ServerMetricsPart
{
/// <summary>
/// Construct a <see cref="ServerMetricsEntity"/>.
/// Construct a <see cref="ServerMetricsPart"/>.
/// </summary>
public ServerMetricsEntity()
public ServerMetricsPart()
{
}

Expand All @@ -34,6 +34,16 @@ public ServerMetricsEntity()
/// </summary>
public long? EventStoreDiskRemainingBytes { get; set; }

/// <summary>
/// The total time spent indexing the event store in the last 24 hours.
/// </summary>
public TimeSpan EventStoreIndexingTimeLastDay { get; set; }

/// <summary>
/// The total time spent writing events to disk in the last minute.
/// </summary>
public TimeSpan EventStoreWriteTimeLastMinute { get; set; }

/// <summary>
/// The number of events that arrived at the ingestion endpoint in the past minute.
/// </summary>
Expand Down
33 changes: 33 additions & 0 deletions src/Seq.Api/Model/Indexes/IndexEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Seq.Api.Model.Indexes
{
/// <summary>
/// An index over the event stream. May be one of several types discriminated by <see cref="IndexedEntityType"/>.
/// </summary>
public class IndexEntity: Entity
{
/// <summary>
/// The `Id` of the associated entity (Signal, Alert or Expression index).
/// </summary>
public string IndexedEntityId { get; set; }

/// <summary>
/// The type of this index.
/// </summary>
public IndexedEntityType IndexedEntityType { get; set; }

/// <summary>
/// The owner / creator of this index.
/// </summary>
public string OwnerUsername { get; set; }

/// <summary>
/// The name of this index. May not be applicable to all index types.
/// </summary>
public string Label { get; set; }

/// <summary>
/// The storage used by this index.
/// </summary>
public ulong StorageBytes { get; set; }
}
}
23 changes: 23 additions & 0 deletions src/Seq.Api/Model/Indexes/IndexedEntityType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Seq.Api.Model.Indexes
{
/// <summary>
/// The type of the index.
/// </summary>
public enum IndexedEntityType
{
/// <summary>
/// A predicate index for a signal expression.
/// </summary>
Signal,

/// <summary>
/// An expression index.
/// </summary>
ExpressionIndex,

/// <summary>
/// A predicate index for an alert filter.
/// </summary>
Alert,
}
}
18 changes: 18 additions & 0 deletions src/Seq.Api/Model/Indexing/ExpressionIndexEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Seq.Api.Model.Indexing
{
/// <summary>
/// An index based on an expression.
/// </summary>
public class ExpressionIndexEntity: Entity
{
/// <summary>
/// The expression to be indexed.
/// </summary>
public string Expression { get; set; }

/// <summary>
/// A user-provided description of the index.
/// </summary>
public string Description { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/Seq.Api/Model/Settings/SettingName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System;
using Seq.Api.Model.Apps;
using Seq.Api.Model.Updates;
using Seq.Api.Model.Users;
using Seq.Api.ResourceGroups;

namespace Seq.Api.Model.Settings
Expand Down Expand Up @@ -124,6 +125,16 @@ public enum SettingName
/// Seq will stop accepting new events.
/// </summary>
MinimumFreeStorageSpace,

/// <summary>
/// A dictionary of `(string, string)` pairs that will be used to initialize the
/// <see cref="UserEntity.Preferences"/> property when preparing new user entities
/// with <see cref="UsersResourceGroup.TemplateAsync"/>, and with automatically
/// provisioning SSO users (when enabled).
/// </summary>
/// <remarks>User preference keys are unconstrained; the Seq UI uses a number of these, but
/// alternative interfaces and integrations may add additional items to this collection.</remarks>
NewUserPreferences,

/// <summary>
/// A comma-separated list of role ids that will be assigned to new users by default.
Expand Down
5 changes: 5 additions & 0 deletions src/Seq.Api/Model/Signals/SignalEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public SignalEntity()
/// If <c>true</c>, the signal can only be modified by users with the <see cref="Permission.Project"/> permission.
/// </summary>
public bool IsProtected { get; set; }

/// <summary>
/// If <c>true</c>, the signal has no backing index.
/// </summary>
public bool IsIndexSuppressed { get; set; }

/// <summary>
/// How the signal is grouped in the Seq UI.
Expand Down
4 changes: 2 additions & 2 deletions src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ internal DiagnosticsResourceGroup(ILoadResourceGroup connection)
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>Current server metrics.</returns>
public async Task<ServerMetricsEntity> GetServerMetricsAsync(CancellationToken cancellationToken = default)
public async Task<ServerMetricsPart> GetServerMetricsAsync(CancellationToken cancellationToken = default)
{
return await GroupGetAsync<ServerMetricsEntity>("ServerMetrics", cancellationToken: cancellationToken).ConfigureAwait(false);
return await GroupGetAsync<ServerMetricsPart>("ServerMetrics", cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down
73 changes: 73 additions & 0 deletions src/Seq.Api/ResourceGroups/ExpressionIndexesResourceGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Seq.Api.Model;
using Seq.Api.Model.Indexing;

namespace Seq.Api.ResourceGroups
{
/// <summary>
/// Perform operations on expression indexes.
/// </summary>
public class ExpressionIndexesResourceGroup: ApiResourceGroup
{
internal ExpressionIndexesResourceGroup(ILoadResourceGroup connection) : base("ExpressionIndexes", connection)
{
}

/// <summary>
/// Retrieve expression indexes.
/// </summary>
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>A list containing matching expression indexes.</returns>
public async Task<List<ExpressionIndexEntity>> ListAsync(CancellationToken cancellationToken = default)
{
return await GroupListAsync<ExpressionIndexEntity>("Items", cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Retrieve the expression index with the given id; throws if the entity does not exist.
/// </summary>
/// <param name="id">The id of the expression index.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>The expression index.</returns>
public async Task<ExpressionIndexEntity> FindAsync(string id, CancellationToken cancellationToken = default)
{
if (id == null) throw new ArgumentNullException(nameof(id));
return await GroupGetAsync<ExpressionIndexEntity>("Item", new Dictionary<string, object> { { "id", id } }, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Construct an expression index with server defaults pre-initialized.
/// </summary>
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>The unsaved expression index.</returns>
public async Task<ExpressionIndexEntity> TemplateAsync(CancellationToken cancellationToken = default)
{
return await GroupGetAsync<ExpressionIndexEntity>("Template", cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Add a new expression index.
/// </summary>
/// <param name="entity">The expression index to add.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>The expression index, with server-allocated properties such as <see cref="Entity.Id"/> initialized.</returns>
public async Task<ExpressionIndexEntity> AddAsync(ExpressionIndexEntity entity, CancellationToken cancellationToken = default)
{
return await GroupCreateAsync<ExpressionIndexEntity, ExpressionIndexEntity>(entity, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Remove an existing expression index.
/// </summary>
/// <param name="entity">The expression index to remove.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>A task indicating completion.</returns>
public async Task RemoveAsync(ExpressionIndexEntity entity, CancellationToken cancellationToken = default)
{
await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
58 changes: 58 additions & 0 deletions src/Seq.Api/ResourceGroups/IndexesResourceGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Seq.Api.Model.Alerting;
using Seq.Api.Model.Indexes;
using Seq.Api.Model.Indexing;
using Seq.Api.Model.Signals;

namespace Seq.Api.ResourceGroups
{
/// <summary>
/// Statistics about indexes.
/// </summary>
public class IndexesResourceGroup : ApiResourceGroup
{
internal IndexesResourceGroup(ILoadResourceGroup connection)
: base("Indexes", connection)
{
}

/// <summary>
/// Retrieve the index with the given id; throws if the entity does not exist.
/// </summary>
/// <param name="id">The id of the index.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>The index.</returns>
public async Task<IndexEntity> FindAsync(string id, CancellationToken cancellationToken = default)
{
if (id == null) throw new ArgumentNullException(nameof(id));
return await GroupGetAsync<IndexEntity>("Item", new Dictionary<string, object> { { "id", id } }, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Retrieve statistics on all indexes.
/// </summary>
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>A list containing matching expression indexes.</returns>
public async Task<List<IndexEntity>> ListAsync(CancellationToken cancellationToken = default)
{
return await GroupListAsync<IndexEntity>("Items", cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Suppress an index. Not all index types can be suppressed: signal indexes do support suppression, in the case
/// of which the <see cref="SignalEntity.IsIndexSuppressed"/> flag will be set to <c langword="false"/>.
/// Expression indexes can only be suppressed by deleting the associated <see cref="ExpressionIndexEntity"/>
/// and alert indexes can only be suppressed by deleting the corresponding <see cref="AlertEntity"/>.
/// </summary>
/// <param name="entity">The index to suppress.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <returns>A task indicating completion.</returns>
public async Task SuppressAsync(IndexEntity entity, CancellationToken cancellationToken = default)
{
await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
1 change: 1 addition & 0 deletions src/Seq.Api/ResourceGroups/SignalsResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public async Task<SignalEntity> AddAsync(SignalEntity entity, CancellationToken
{
return await GroupCreateAsync<SignalEntity, SignalEntity>(entity, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Remove an existing signal.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Api/Seq.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Client library for the Seq HTTP API.</Description>
<VersionPrefix>2024.2.0</VersionPrefix>
<VersionPrefix>2024.3.0</VersionPrefix>
<Authors>Datalust;Contributors</Authors>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
10 changes: 10 additions & 0 deletions src/Seq.Api/SeqConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,22 @@ public void Dispose()
/// Perform operations on queries and filter expressions.
/// </summary>
public ExpressionsResourceGroup Expressions => new ExpressionsResourceGroup(this);

/// <summary>
/// Perform operations on expression indexes.
/// </summary>
public ExpressionIndexesResourceGroup ExpressionIndexes => new ExpressionIndexesResourceGroup(this);

/// <summary>
/// Perform operations on NuGet feeds.
/// </summary>
public FeedsResourceGroup Feeds => new FeedsResourceGroup(this);

/// <summary>
/// Statistics about indexes.
/// </summary>
public IndexesResourceGroup Indexes => new IndexesResourceGroup(this);

/// <summary>
/// Perform operations on the Seq license certificate.
/// </summary>
Expand Down

0 comments on commit 78b71d9

Please sign in to comment.