Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seq 2021.3 API updates #103

Merged
merged 2 commits into from
Oct 22, 2021
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
13 changes: 13 additions & 0 deletions src/Seq.Api/Model/Alerting/AlertActivityPart.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;

// ReSharper disable UnusedAutoPropertyAccessor.Global

namespace Seq.Api.Model.Alerting
Expand Down Expand Up @@ -39,9 +40,21 @@ public class AlertActivityPart
/// </summary>
public List<AlertOccurrencePart> RecentOccurrences { get; set; } = new List<AlertOccurrencePart>();

/// <summary>
/// Minimal metrics for the most recent occurrences of the alert that triggered notifications.
/// The metrics in this list are a superset of <see cref="RecentOccurrences"/>.
/// </summary>
public List<AlertOccurrenceRangePart> RecentOccurrenceRanges { get; set; } =
new List<AlertOccurrenceRangePart>();

/// <summary>
/// The number of times this alert has been triggered since its creation.
/// </summary>
public int TotalOccurrences { get; set; }

/// <summary>
/// The detection time of the most recent occurrence not included in <see cref="RecentOccurrences"/>.
/// </summary>
public DateTime? LastEarlierOccurrence { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/Seq.Api/Model/Alerting/AlertOccurrenceRangePart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Shared;

namespace Seq.Api.Model.Alerting
{
/// <summary>
/// An occurrence metric of an alert that triggered notifications.
/// </summary>
public class AlertOccurrenceRangePart
{
/// <summary>
/// The time grouping that triggered the alert.
/// </summary>
public DateTimeRange DetectedOverRange { get; set; }
}
}
7 changes: 1 addition & 6 deletions src/Seq.Api/Model/Apps/AppPackagePart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public class AppPackagePart
/// Package authorship information.
/// </summary>
public string Authors { get; set; }

/// <summary>
/// URL of an icon for the app package.
/// </summary>
public string IconUrl { get; set; }


/// <summary>
/// URL of the package license.
/// </summary>
Expand Down
15 changes: 12 additions & 3 deletions src/Seq.Api/ResourceGroups/AlertsResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Threading.Tasks;
using Seq.Api.Model;
using Seq.Api.Model.Alerting;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Users;

namespace Seq.Api.ResourceGroups
Expand Down Expand Up @@ -55,17 +56,25 @@ public async Task<AlertEntity> FindAsync(string id, CancellationToken cancellati
public async Task<List<AlertEntity>> ListAsync(string ownerId = null, bool shared = false, CancellationToken cancellationToken = default)
{
var parameters = new Dictionary<string, object> { { "ownerId", ownerId }, { "shared", shared } };
return await GroupListAsync<AlertEntity>("Items", parameters, cancellationToken: cancellationToken).ConfigureAwait(false);
return await GroupListAsync<AlertEntity>("Items", parameters, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Construct a alert with server defaults pre-initialized.
/// </summary>
/// <param name="cancellationToken"><see cref="CancellationToken"/> allowing the operation to be canceled.</param>
/// <param name="signal">The source of events that will contribute to the alert.</param>
/// <param name="query">An SQL query that will supply default clauses to the new alert.</param>
/// <returns>The unsaved alert.</returns>
public async Task<AlertEntity> TemplateAsync(CancellationToken cancellationToken = default)
public async Task<AlertEntity> TemplateAsync(SignalExpressionPart signal = null, string query = null, CancellationToken cancellationToken = default)
{
return await GroupGetAsync<AlertEntity>("Template", cancellationToken: cancellationToken).ConfigureAwait(false);
var parameters = new Dictionary<string, object>
{
["signal"] = signal?.ToString(),
["q"] = query
};

return await GroupGetAsync<AlertEntity>("Template", parameters, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down