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
47 changes: 47 additions & 0 deletions src/Seq.Api/Model/Alerting/AlertActivityPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
// ReSharper disable UnusedAutoPropertyAccessor.Global

namespace Seq.Api.Model.Alerting
{
/// <summary>
/// A summary of recent activity on an alert.
/// </summary>

public class AlertActivityPart
{
/// <summary>
/// When the last check for the alert was performed.
/// </summary>
public DateTime? LastCheck { get; set; }

/// <summary>
/// Whether or not the last check triggered any notifications.
/// </summary>
public bool LastCheckTriggered { get; set; }

/// <summary>
/// Any failures that prevented the last check from completing successfully.
/// These failures indicate a problem with the alert itself, not with the
/// data being monitored.
///
/// A value of <c>null</c> indicates the last check succeeded.
/// </summary>
public List<string> LastCheckFailures { get; set; }

/// <summary>
/// When the alert may be checked again after being triggered.
/// </summary>
public DateTime? SuppressedUntil { get; set; }

/// <summary>
/// The most recent occurrences of the alert that triggered notifications.
/// </summary>
public List<AlertOccurrencePart> RecentOccurrences { get; set; } = new List<AlertOccurrencePart>();

/// <summary>
/// The number of times this alert has been triggered since its creation.
/// </summary>
public int TotalOccurrences { get; set; }
}
}
111 changes: 111 additions & 0 deletions src/Seq.Api/Model/Alerting/AlertEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright Datalust and contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Security;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;

namespace Seq.Api.Model.Alerting
{
/// <summary>
/// An alert.
/// </summary>
public class AlertEntity : Entity
{
/// <summary>
/// A friendly, human-readable title for the alert.
/// </summary>
public string Title { get; set; }

/// <summary>
/// An optional long-form description of the alert.
/// </summary>
public string Description { get; set; }

/// <summary>
/// The user id of the user who owns the alert; if <c>null</c>, the alert is shared.
/// </summary>
public string OwnerId { get; set; }

/// <summary>
/// If <c>true</c>, the alert can only be modified by users with the <see cref="Permission.Setup"/> permission.
/// </summary>
public bool IsProtected { get; set; }

/// <summary>
/// If <c>true</c>, the alert will not be processed, and notifications will not be sent.
/// </summary>
public bool IsDisabled { get; set; }

/// <summary>
/// An optional <see cref="SignalExpressionPart"/> limiting the data source that triggers the alert.
/// </summary>
public SignalExpressionPart SignalExpression { get; set; }

/// <summary>
/// An optional <c>where</c> clause limiting the data source that triggers the alert.
/// </summary>
public string Where { get; set; }

/// <summary>
/// Additional groupings applied to the data source. The <c>time()</c> grouping is controlled by the alerting
/// infrastructure according to the <see cref="TimeGrouping"/> property and should not be specified here.
/// </summary>
public List<GroupingColumnPart> GroupBy { get; set; } = new List<GroupingColumnPart>();

/// <summary>
/// The interval over which the alert condition will be measured.
/// </summary>
public TimeSpan TimeGrouping { get; set; }

/// <summary>
/// The individual measurements that will be tested by the alert condition.
/// </summary>
public List<ColumnPart> Select { get; set; } = new List<ColumnPart>();

/// <summary>
/// The alert condition. This is a <c>having</c> clause over the grouped results
/// computed by the alert query.
/// </summary>
public string Having { get; set; }

/// <summary>
/// A level indicating the severity or priority of the alert.
/// </summary>
public LogEventLevel NotificationLevel { get; set; }

/// <summary>
/// Additional properties that will be attached to the generated notification.
/// </summary>
public List<EventPropertyPart> NotificationProperties { get; set; } = new List<EventPropertyPart>();

/// <summary>
/// The channels that will receive notifications when the alert is triggered.
/// </summary>
public List<NotificationChannelPart> NotificationChannels { get; set; } = new List<NotificationChannelPart>();

/// <summary>
/// The time after the alert is triggered within which no further notifications will be sent.
/// </summary>
public TimeSpan SuppressionTime { get; set; }

/// <summary>
/// Any recent activity for the alert.
/// </summary>
public AlertActivityPart Activity { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/Seq.Api/Model/Alerting/AlertNotificationPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Seq.Api.Model.AppInstances;

namespace Seq.Api.Model.Alerting
{
/// <summary>
/// A record of the <see cref="NotificationChannelPart"/> that was notified of an alert occurrence.
/// </summary>
public class AlertNotificationPart
{
/// <summary>
/// The <see cref="AppInstanceEntity" /> that was notified.
/// This id is a historical record, so it may be for app instance that no longer exists.
/// </summary>
public string HistoricalAppInstanceId { get; set; }
}
}
34 changes: 34 additions & 0 deletions src/Seq.Api/Model/Alerting/AlertOccurrencePart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using Seq.Api.Model.AppInstances;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Shared;

namespace Seq.Api.Model.Alerting
{
/// <summary>
/// An occurrence of an alert that triggered notifications.
/// </summary>
public class AlertOccurrencePart
{
/// <summary>
/// The time when the alert was checked and triggered.
/// </summary>
public DateTime DetectedAt { get; set; }

/// <summary>
/// The time grouping that triggered the alert.
/// </summary>
public DateTimeRange DetectedOverRange { get; set; }

/// <summary>
/// The level of notifications sent for this instance.
/// </summary>
public LogEventLevel NotificationLevel { get; set; }

/// <summary>
/// The <see cref="NotificationChannelPart">NotificationChannelParts</see> that were alerted.
/// </summary>
public List<AlertNotificationPart> Notifications { get; set; } = new List<AlertNotificationPart>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

using System;
using System.Collections.Generic;

namespace Seq.Api.Model.Monitoring
namespace Seq.Api.Model.Alerting
{
/// <summary>
/// Describes the state of an active alert.
Expand All @@ -31,30 +32,15 @@ public class AlertStateEntity : Entity
/// </summary>
public string Title { get; set; }

/// <summary>
/// The title of the chart to which the alert is attached.
/// </summary>
public string ChartTitle { get; set; }

/// <summary>
/// The title of the dashboards in which the alert is set.
/// </summary>
public string DashboardTitle { get; set; }

/// <summary>
/// The user id of the user who owns the alert; if <c>null</c>, the alert is shared.
/// </summary>
public string OwnerId { get; set; }

/// <summary>
/// The notification level associated with the alert.
/// </summary>
public string Level { get; set; }

/// <summary>
/// The id of an app instance that will receive notifications when the alert is triggered.
/// The ids of app instances that receive notifications when the alert is triggered.
/// </summary>
public string NotificationAppInstanceId { get; set; }
public List<string> NotificationAppInstanceIds { get; set; }

/// <summary>
/// The time at which the alert was last checked. Not preserved across server restarts.
Expand Down
63 changes: 63 additions & 0 deletions src/Seq.Api/Model/Alerting/NotificationChannelPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright Datalust and contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using Seq.Api.Model.AppInstances;

namespace Seq.Api.Model.Alerting
{
/// <summary>
/// A notification channel belonging to an alert.
/// </summary>
public class NotificationChannelPart
{
/// <summary>
/// A system-assigned identifier for the channel. This is used when updating channels to carry over unchanged
/// values of sensitive settings, which are not round-tripped to the client for editing. When creating a
/// new channel, this should be <c>null</c>.
/// </summary>
public string Id { get; set; }

/// <summary>
/// The message used for the title or subject of the notification. If not specified, a default message based
/// on the alert title will be used.
/// </summary>
public string NotificationMessage { get; set; }

/// <summary>
/// If <c>true</c>, notifications will include a sample of the events that contributed to the triggering of
/// the alert.
/// </summary>
public bool IncludeContributingEvents { get; set; }

/// <summary>
/// When <see cref="IncludeContributingEvents"/> is <c>true</c>, the maximum number of contributing events to
/// include in the notification. Note that this value is an upper limit, and server resource constraints may
/// prevent all contributing events from being included even below this limit.
/// </summary>
public uint? IncludedContributingEventLimit { get; set; }

/// <summary>
/// The id of an <see cref="AppInstanceEntity"/> that will receive notifications from the alert.
/// </summary>
public string NotificationAppInstanceId { get; set; }

/// <summary>
/// Additional properties that will be used to configure the notification app when triggered
/// by the alert.
/// </summary>
public Dictionary<string, string> NotificationAppSettingOverrides { get; set; } =
new Dictionary<string, string>();
}
}
53 changes: 53 additions & 0 deletions src/Seq.Api/Model/Cluster/ClusterNodeEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright Datalust and contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Seq.Api.Model.Cluster
{
/// <summary>
/// Describes a node in a Seq cluster.
/// </summary>
public class ClusterNodeEntity : Entity
{
/// <summary>
/// The role the node is currently acting in.
/// </summary>
public NodeRole Role { get; set; }

/// <summary>
/// An informational name associated with the node.
/// </summary>
public string Name { get; set; }

/// <summary>
/// An informational representation of the storage generation committed to the node.
/// </summary>
public string Generation { get; set; }

/// <summary>
/// Whether any writes have occurred since the node's last completed sync.
/// </summary>
public bool? IsUpToDate { get; set; }

/// <summary>
/// The time since the node's last completed sync operation.
/// </summary>
public double? MillisecondsSinceLastSync { get; set; }

/// <summary>
/// An informational description of the node's current state, or <c langword="null">null</c> if no additional
/// information about the node is available.
/// </summary>
public string StateDescription { get; set; }
}
}
Loading