diff --git a/src/Seq.Api/Client/SeqApiClient.cs b/src/Seq.Api/Client/SeqApiClient.cs index 2108ac1..12d8f88 100644 --- a/src/Seq.Api/Client/SeqApiClient.cs +++ b/src/Seq.Api/Client/SeqApiClient.cs @@ -42,7 +42,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 utilized. - const string SeqApiV7MediaType = "application/vnd.datalust.seq.v7+json"; + const string SeqApiV8MediaType = "application/vnd.datalust.seq.v8+json"; readonly CookieContainer _cookies = new CookieContainer(); readonly JsonSerializer _serializer = JsonSerializer.Create( @@ -89,7 +89,7 @@ public SeqApiClient(string serverUrl, string apiKey = null, Action(); InvocationOverridableSettingDefinitions = new List(); EventsPerSuppressionWindow = 1; - Metrics = new AppInstanceMetricsPart(); + ProcessMetrics = new AppInstanceProcessMetricsPart(); + InputSettings = new InputSettingsPart(); + InputMetrics = new InputMetricsPart(); + DiagnosticInputMetrics = new InputMetricsPart(); + OutputMetrics = new AppInstanceOutputMetricsPart(); } /// @@ -90,7 +95,7 @@ public AppInstanceEntity() /// The signal expression describing which events will be sent to the app; if null, /// all events will reach the app. /// - public SignalExpressionPart InputSignalExpression { get; set; } + public SignalExpressionPart StreamedSignalExpression { get; set; } /// /// If a value is specified, events will be buffered to disk and sorted by timestamp-order @@ -113,22 +118,46 @@ public AppInstanceEntity() public int EventsPerSuppressionWindow { get; set; } /// - /// Metrics describing the state and activity of the app. + /// Settings that control how events are ingested through the app. /// [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public AppInstanceMetricsPart Metrics { get; set; } + public InputSettingsPart InputSettings { get; set; } + /// + /// Metrics describing the state and activity of the app process. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public AppInstanceProcessMetricsPart ProcessMetrics { get; set; } + + /// + /// Information about ingestion activity through this app. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public InputMetricsPart InputMetrics { get; set; } + + /// + /// Information about the app's diagnostic input. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public InputMetricsPart DiagnosticInputMetrics { get; set; } + + /// + /// Information about events output through the app. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public AppInstanceOutputMetricsPart OutputMetrics { get; set; } + /// /// Obsolete. /// - [Obsolete("Use !AcceptStreamedEvents instead. This field will be removed in Seq 6.0.")] + [Obsolete("Use !AcceptStreamedEvents instead.")] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool? IsManualInputOnly { get; set; } /// /// Obsolete. /// - [Obsolete("Use !AcceptDirectInvocation instead. This field will be removed in Seq 6.0.")] + [Obsolete("Use !AcceptDirectInvocation instead.")] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool? DisallowManualInput { get; set; } } diff --git a/src/Seq.Api/Model/AppInstances/AppInstanceOutputMetricsPart.cs b/src/Seq.Api/Model/AppInstances/AppInstanceOutputMetricsPart.cs new file mode 100644 index 0000000..d0f36bb --- /dev/null +++ b/src/Seq.Api/Model/AppInstances/AppInstanceOutputMetricsPart.cs @@ -0,0 +1,15 @@ +namespace Seq.Api.Model.AppInstances +{ + /// + /// Describes the events reaching being output from Seq through the app. + /// + public class AppInstanceOutputMetricsPart + { + /// + /// The number of events per minute sent from Seq to the app. Includes streamed events (if enabled), + /// manual invocations, and alert notifications. There may be some delay between dispatching an event, and + /// it being processed by the app. + /// + public int DispatchedEventsPerMinute { get; set; } + } +} diff --git a/src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs b/src/Seq.Api/Model/AppInstances/AppInstanceProcessMetricsPart.cs similarity index 61% rename from src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs rename to src/Seq.Api/Model/AppInstances/AppInstanceProcessMetricsPart.cs index bcf348c..9eb9794 100644 --- a/src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs +++ b/src/Seq.Api/Model/AppInstances/AppInstanceProcessMetricsPart.cs @@ -15,25 +15,14 @@ namespace Seq.Api.Model.AppInstances { /// - /// Metrics describing an . + /// Metrics describing the running server-side process for an . /// - public class AppInstanceMetricsPart + public class AppInstanceProcessMetricsPart { - /// - /// The number of events that reached the app in the past minute. - /// - public int ReceivedEventsPerMinute { get; set; } - - /// - /// The number of diagnostic events raised by the app in the past minute. - /// - /// This does not include the events received by an input app. - public int EmittedEventsPerMinute { get; set; } - /// /// The size, in bytes, of the app process working set. /// - public long ProcessWorkingSetBytes { get; set; } + public long WorkingSetBytes { get; set; } /// /// If the app process is running, true; otherwise, false. diff --git a/src/Seq.Api/Model/Diagnostics/MeasurementTimeseriesPart.cs b/src/Seq.Api/Model/Diagnostics/MeasurementTimeseriesPart.cs new file mode 100644 index 0000000..50efe27 --- /dev/null +++ b/src/Seq.Api/Model/Diagnostics/MeasurementTimeseriesPart.cs @@ -0,0 +1,39 @@ +// 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; + +namespace Seq.Api.Model.Diagnostics +{ + /// + /// A histogram presenting a measurement taken at equal intervals. + /// + public class MeasurementTimeseriesPart + { + /// + /// The point in time from which measurement begins. + /// + public DateTime MeasuredFrom { get; set; } + + /// + /// The interval at which the measurement is taken. + /// + public ulong MeasurementIntervalMilliseconds { get; set; } + + /// + /// The measurements at each interval, beginning with . + /// + public long[] Measurements { get; set; } + } +} diff --git a/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs b/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs index 63051ea..bca4e1c 100644 --- a/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs +++ b/src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs @@ -27,7 +27,6 @@ public class ServerMetricsEntity : Entity /// public ServerMetricsEntity() { - RunningTasks = new List(); } /// @@ -40,16 +39,6 @@ public ServerMetricsEntity() /// public int EventStoreEventsCached { get; set; } - /// - /// The oldest on-disk extent currently stored. - /// - public DateTime? EventStoreFirstExtentRangeStartUtc { get; set; } - - /// - /// The most recent on-disk extent currently stored. - /// - public DateTime? EventStoreLastExtentRangeEndUtc { get; set; } - /// /// Bytes of free space remaining on the disk used for event storage. /// @@ -58,27 +47,27 @@ public ServerMetricsEntity() /// /// The number of events that arrived at the ingestion endpoint in the past minute. /// - public int EndpointArrivalsPerMinute { get; set; } + public int InputArrivedEventsPerMinute { get; set; } /// /// The number of events ingested in the past minute. /// - public int EndpointInfluxPerMinute { get; set; } + public int InputIngestedEventsPerMinute { get; set; } /// /// The number of bytes of raw JSON event data ingested in the past minute (approximate). /// - public long EndpointIngestedBytesPerMinute { get; set; } + public long InputIngestedBytesPerMinute { get; set; } /// /// The number of invalid event payloads seen in the past minute. /// - public int EndpointInvalidPayloadsPerMinute { get; set; } + public int InvalidPayloadsPerMinute { get; set; } /// /// The number of unauthorized event payloads seen in the past minute. /// - public int EndpointUnauthorizedPayloadsPerMinute { get; set; } + public int HttpUnauthorizedPayloadsPerMinute { get; set; } /// /// The length of time for which the Seq server process has been running. @@ -95,26 +84,11 @@ public ServerMetricsEntity() /// public int ProcessThreads { get; set; } - /// - /// The number of thread pool user threads available. - /// - public int ProcessThreadPoolUserThreadsAvailable { get; set; } - - /// - /// The number of async I/O thread pool threads available. - /// - public int ProcessThreadPoolIocpThreadsAvailable { get; set; } - /// /// The proportion of system physical memory that is currently allocated. /// public double SystemMemoryUtilization { get; set; } - /// - /// Tasks running in the Seq server. - /// - public List RunningTasks { get; set; } - /// /// The number of SQL-style queries executed in the past minute. /// @@ -129,10 +103,5 @@ public ServerMetricsEntity() /// The number of cached SQL query time slices invalidated in the past minute. /// public int QueryCacheInvalidationsPerMinute { get; set; } - - /// - /// The number of active sessions reading from or writing to Seq's internal metadata store. - /// - public int DocumentStoreActiveSessions { get; set; } } } diff --git a/src/Seq.Api/Model/Entity.cs b/src/Seq.Api/Model/Entity.cs index 23e0825..67a9408 100644 --- a/src/Seq.Api/Model/Entity.cs +++ b/src/Seq.Api/Model/Entity.cs @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + namespace Seq.Api.Model { /// @@ -41,5 +46,12 @@ protected Entity() /// was instantiated locally and not received from the API. /// public LinkCollection Links { get; set; } + + /// + /// Facilitates backwards compatibility in the Seq server. Should not be used by consumers/clients. + /// + [JsonExtensionData, JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + [Obsolete("Facilitates backwards compatibility in the Seq server. Should not be used by consumers/clients.")] + public Dictionary ExtensionData { get; set; } } } diff --git a/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs b/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs index f755713..bb0c4a6 100644 --- a/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs +++ b/src/Seq.Api/Model/Inputs/ApiKeyEntity.cs @@ -14,9 +14,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -using Seq.Api.Model.LogEvents; using Seq.Api.Model.Security; -using Seq.Api.Model.Signals; namespace Seq.Api.Model.Inputs { @@ -33,10 +31,10 @@ public class ApiKeyEntity : Entity public string Title { get; set; } /// - /// The API key token. API keys generated for versions of Seq prior to 5.0 will expose this value. From 5.0 onwards, - /// can be specified explicitly when creating an API key, but is not readable once the API key is created. - /// Leaving the token blank will cause the server to generate a cryptographically random API key token. After creation, the first - /// few characters of the token will be readable from , but because only a cryptographically-secure + /// The API key token. can be specified explicitly when creating an API key, but is not + /// readable once the API key is created. Leaving the token blank will cause the server to generate a + /// cryptographically random API key token. After creation, the first few (additional, redundant) characters + /// of the token will be readable from , but because only a cryptographically-secure /// hash of the token is stored internally, the token itself cannot be retrieved. /// public string Token { get; set; } @@ -47,31 +45,12 @@ public class ApiKeyEntity : Entity public string TokenPrefix { get; set; } /// - /// Properties that will be automatically added to all events ingested using the key. These will override any properties with - /// the same names already present on the event. + /// Settings that control how events are ingested through the API key. /// - public List AppliedProperties { get; set; } = new List(); + public InputSettingsPart InputSettings { get; set; } = new InputSettingsPart(); /// - /// A filter that selects events to ingest. If null, all events received using the key will be ingested. - /// - public SignalFilterPart InputFilter { get; set; } = new SignalFilterPart(); - - /// - /// A minimum level at which events received using the key will be ingested. The level hierarchy understood by Seq is fuzzy - /// enough to handle most common leveling schemes. This value will be provided to callers so that they can dynamically - /// filter events client-side, if supported. - /// - public LogEventLevel? MinimumLevel { get; set; } - - /// - /// If true, timestamps already present on the events will be ignored, and server timestamps used instead. This is not - /// recommended for most use cases. - /// - public bool UseServerTimestamps { get; set; } - - /// - /// If true, the key is the built-in (tokenless) API key. + /// If true, the key is the built-in (tokenless) API key representing unauthenticated HTTP ingestion. /// public bool IsDefault { get; set; } @@ -90,6 +69,6 @@ public class ApiKeyEntity : Entity /// Information about the ingestion activity using this API key. /// [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public ApiKeyMetricsPart Metrics { get; set; } = new ApiKeyMetricsPart(); + public InputMetricsPart InputMetrics { get; set; } = new InputMetricsPart(); } } diff --git a/src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs b/src/Seq.Api/Model/Inputs/InputMetricsPart.cs similarity index 57% rename from src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs rename to src/Seq.Api/Model/Inputs/InputMetricsPart.cs index 7e431ad..7e96fe7 100644 --- a/src/Seq.Api/Model/Inputs/ApiKeyMetricsPart.cs +++ b/src/Seq.Api/Model/Inputs/InputMetricsPart.cs @@ -17,24 +17,28 @@ namespace Seq.Api.Model.Inputs /// /// Information about ingestion activity using an API key. /// - public class ApiKeyMetricsPart + public class InputMetricsPart { /// - /// The number of events that arrived at the server tagged with this - /// key in the past minute. + /// The number of events that arrived at the server from this input in the past minute. /// - public int ArrivalsPerMinute { get; set; } + public int ArrivedEventsPerMinute { get; set; } /// - /// The number of events that ingested by the server tagged with this - /// key in the past minute. + /// The number of events that ingested by the server from this input in the past minute. /// - public int InfluxPerMinute { get; set; } + public int IngestedEventsPerMinute { get; set; } /// - /// The raw JSON bytes (approximate) tagged with this API key that were ingested + /// The raw JSON bytes (approximate) from this input that were ingested /// by the server in the past minute. /// public long IngestedBytesPerMinute { get; set; } + + /// + /// The number of invalid payloads reaching this input in the past minute. Invalid payloads includes malformed + /// and oversized JSON event bodies, as well as malformed or oversized batches. + /// + public long InvalidPayloadsPerMinute { get; set; } } } \ No newline at end of file diff --git a/src/Seq.Api/Model/Inputs/InputSettingsPart.cs b/src/Seq.Api/Model/Inputs/InputSettingsPart.cs new file mode 100644 index 0000000..540b566 --- /dev/null +++ b/src/Seq.Api/Model/Inputs/InputSettingsPart.cs @@ -0,0 +1,51 @@ +// 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.LogEvents; +using Seq.Api.Model.Shared; +using Seq.Api.Model.Signals; + +namespace Seq.Api.Model.Inputs +{ + /// + /// Settings carried by API keys, (input) app instances, and other inputs. + /// + public class InputSettingsPart + { + /// + /// Properties that will be automatically added to all events ingested using the key. These will override any properties with + /// the same names already present on the event. + /// + public List AppliedProperties { get; set; } = new List(); + + /// + /// A filter that selects events to ingest. If null, all events received using the key will be ingested. + /// + public DescriptiveFilterPart Filter { get; set; } = new DescriptiveFilterPart(); + + /// + /// A minimum level at which events received using the key will be ingested. The level hierarchy understood by Seq is fuzzy + /// enough to handle most common leveling schemes. This value will be provided to callers so that they can dynamically + /// filter events client-side, if supported. + /// + public LogEventLevel? MinimumLevel { get; set; } + + /// + /// If true, timestamps already present on the events will be ignored, and server timestamps used instead. This is not + /// recommended for most use cases. + /// + public bool UseServerTimestamps { get; set; } + } +} \ No newline at end of file diff --git a/src/Seq.Api/Model/Settings/SettingName.cs b/src/Seq.Api/Model/Settings/SettingName.cs index 5740a87..d6e48f8 100644 --- a/src/Seq.Api/Model/Settings/SettingName.cs +++ b/src/Seq.Api/Model/Settings/SettingName.cs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using Seq.Api.Model.Apps; using Seq.Api.Model.Updates; using Seq.Api.ResourceGroups; @@ -24,6 +25,12 @@ namespace Seq.Api.Model.Settings /// public enum SettingName { + /// + /// The authentication provider to use. Allowed values are null (local username/password), + /// "Active Directory", "Azure Active Directory" and "OpenID Connect". + /// + AuthenticationProvider, + /// /// The name of an Active Directory group within which users will be automatically /// be granted user access to Seq. @@ -34,8 +41,21 @@ public enum SettingName /// If true, Azure Active Directory accounts in the configured tenant will /// be automatically granted user access to Seq. /// + [Obsolete("Use `AutomaticallyProvisionAuthenticatedUsers`.", error: true)] AutomaticallyGrantUserAccessToADAccounts, + + /// + /// If true, users authenticated with the configured authentication provider + /// be automatically granted default user access to Seq. + /// + AutomaticallyProvisionAuthenticatedUsers, + /// + /// The AAD authority. The default is login.windows.net; government cloud users may + /// require login.microsoftonline.us or similar. + /// + AzureADAuthority, + /// /// The Azure Active Directory client id. /// @@ -87,6 +107,7 @@ public enum SettingName /// /// If true, the server supports Active Directory authentication. /// + [Obsolete("Set `AuthenticationProvider` to \"Active Directory\" to enable.", error: true)] IsActiveDirectoryAuthentication, /// @@ -94,11 +115,6 @@ public enum SettingName /// IsAuthenticationEnabled, - /// - /// Obsolete. - /// - LazilyFlushEventWrites, - /// /// Tracks whether an admin user has dismissed the master key backup warning. /// @@ -133,6 +149,28 @@ public enum SettingName /// NewUserShowDashboardIds, + /// + /// If using OpenID Connect authentication, the URL of the authorization endpoint. For example, + /// https://example.com. + /// + OpenIdConnectAuthority, + + /// + /// If using OpenID Connect, the client id assigned to Seq in the provider. + /// + OpenIdConnectClientId, + + /// + /// If using OpenID Connect, the client secret assigned to Seq in the provider. + /// + OpenIdConnectClientSecret, + + /// + /// If using OpenID Connect, the scopes Seq will request when authorizing the client, as a comma-separated + /// list. For example, openid, profile, email. + /// + OpenIdConnectScopes, + /// /// If true, ingestion requests incoming via HTTP must be authenticated using an API key or /// logged-in user session. Only effective when is true. diff --git a/src/Seq.Api/Model/Signals/SignalFilterPart.cs b/src/Seq.Api/Model/Shared/DescriptiveFilterPart.cs similarity index 91% rename from src/Seq.Api/Model/Signals/SignalFilterPart.cs rename to src/Seq.Api/Model/Shared/DescriptiveFilterPart.cs index 7f77324..05761de 100644 --- a/src/Seq.Api/Model/Signals/SignalFilterPart.cs +++ b/src/Seq.Api/Model/Shared/DescriptiveFilterPart.cs @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Seq.Api.Model.Signals +namespace Seq.Api.Model.Shared { /// - /// An individual filter incorporated within a signal. + /// An expression-based filter that carries additional descriptive information. /// - public class SignalFilterPart + public class DescriptiveFilterPart { /// /// A friendly, human-readable description of the filter. diff --git a/src/Seq.Api/Model/Signals/SignalEntity.cs b/src/Seq.Api/Model/Signals/SignalEntity.cs index 0c266d0..38f8e62 100644 --- a/src/Seq.Api/Model/Signals/SignalEntity.cs +++ b/src/Seq.Api/Model/Signals/SignalEntity.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using Seq.Api.Model.Security; +using Seq.Api.Model.Shared; namespace Seq.Api.Model.Signals { @@ -30,7 +31,7 @@ public class SignalEntity : Entity public SignalEntity() { Title = "New Signal"; - Filters = new List(); + Filters = new List(); Columns = new List(); } @@ -47,7 +48,7 @@ public SignalEntity() /// /// Filters that are combined (using the and operator) to identify events matching the filter. /// - public List Filters { get; set; } + public List Filters { get; set; } /// /// Expressions that show as columns when the signal is selected in the events screen. diff --git a/src/Seq.Api/Model/Diagnostics/RunningTaskPart.cs b/src/Seq.Api/Model/Tasks/RunningTaskEntity.cs similarity index 85% rename from src/Seq.Api/Model/Diagnostics/RunningTaskPart.cs rename to src/Seq.Api/Model/Tasks/RunningTaskEntity.cs index fc6c2fd..ce713e8 100644 --- a/src/Seq.Api/Model/Diagnostics/RunningTaskPart.cs +++ b/src/Seq.Api/Model/Tasks/RunningTaskEntity.cs @@ -14,18 +14,13 @@ using System; -namespace Seq.Api.Model.Diagnostics +namespace Seq.Api.Model.Tasks { /// /// Describes a task being actively performed by the Seq server. /// - public class RunningTaskPart + public class RunningTaskEntity: Entity { - /// - /// A unique identifier for the task. - /// - public Guid Id { get; set; } - /// /// A description of the task. /// @@ -35,5 +30,10 @@ public class RunningTaskPart /// When the task started. /// public DateTime StartedAtUtc { get; set; } + + /// + /// Whether or not the task can be cancelled. + /// + public bool CanCancel { get; set; } } -} \ No newline at end of file +} diff --git a/src/Seq.Api/Model/Users/UserEntity.cs b/src/Seq.Api/Model/Users/UserEntity.cs index d206fab..81002f1 100644 --- a/src/Seq.Api/Model/Users/UserEntity.cs +++ b/src/Seq.Api/Model/Users/UserEntity.cs @@ -13,6 +13,8 @@ // limitations under the License. using System.Collections.Generic; +using Newtonsoft.Json; +using Seq.Api.Model.Shared; using Seq.Api.Model.Signals; namespace Seq.Api.Model.Users @@ -46,19 +48,22 @@ public class UserEntity : Entity /// /// If changing password, the new password for the user. /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string NewPassword { get; set; } /// /// A filter that is applied to searches and queries instigated by /// the user. /// - public SignalFilterPart ViewFilter { get; set; } + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public DescriptiveFilterPart ViewFilter { get; set; } /// /// If true, the user will be unable to log in without first /// changing their password. Recommended when administratively assigning /// a password for the user. /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool MustChangePassword { get; set; } /// @@ -66,5 +71,21 @@ public class UserEntity : Entity /// the Seq UI currently only supports a single role when editing users. /// public HashSet RoleIds { get; set; } = new HashSet(); + + /// + /// The authentication provider associated with the user account. This will normally be + /// the system-configured authentication provider, but if the provider is changed, the + /// user may need to be unlinked from an existing provider so that login can proceed through + /// the new provider. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public string AuthenticationProvider { get; set; } + + /// + /// The unique identifier that links the identity provided by the authentication provider + /// with the Seq user. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public string AuthenticationProviderUniqueIdentifier { get; set; } } } diff --git a/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs b/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs index 2ad1fb9..8b8fa17 100644 --- a/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AlertStateResourceGroup.cs @@ -21,7 +21,7 @@ namespace Seq.Api.ResourceGroups { /// - /// Inspect the current states of alerts being monitored by the server.. + /// Inspect the current states of alerts being monitored by the server. /// public class AlertStateResourceGroup : ApiResourceGroup { diff --git a/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs b/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs index 7de4f5c..883ec1d 100644 --- a/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/ApiKeysResourceGroup.cs @@ -17,6 +17,7 @@ using System.Threading; using System.Threading.Tasks; using Seq.Api.Model; +using Seq.Api.Model.Diagnostics; using Seq.Api.Model.Inputs; using Seq.Api.Model.Users; @@ -107,5 +108,18 @@ public async Task UpdateAsync(ApiKeyEntity entity, CancellationToken cancellatio { await Client.PutAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Retrieve a detailed metric for the API key. + /// + /// The API key to retrieve metrics for. + /// A allowing the operation to be canceled. + /// The measurement to get. + /// + public async Task GetMeasurementTimeseriesAsync(ApiKeyEntity entity, string measurement, CancellationToken cancellationToken = default) + { + var parameters = new Dictionary{ ["id"] = entity.Id, ["measurement"] = measurement }; + return await GroupGetAsync("Metric", parameters, cancellationToken); + } } } diff --git a/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs b/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs index 1a16f39..0ee6737 100644 --- a/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/AppInstancesResourceGroup.cs @@ -19,6 +19,7 @@ using Seq.Api.Model; using Seq.Api.Model.AppInstances; using Seq.Api.Model.Apps; +using Seq.Api.Model.Diagnostics; namespace Seq.Api.ResourceGroups { @@ -122,5 +123,18 @@ public async Task InvokeAsync(AppInstanceEntity entity, string eventId, IReadOnl var postedSettings = settingOverrides ?? new Dictionary(); await Client.PostAsync(entity, "Invoke", postedSettings, new Dictionary{{"eventId", eventId}}, cancellationToken); } + + /// + /// Retrieve a detailed metric for the app instance. + /// + /// The app instance to retrieve metrics for. + /// A allowing the operation to be canceled. + /// The measurement to get. + /// + public async Task GetMeasurementTimeseriesAsync(AppInstanceEntity entity, string measurement, CancellationToken cancellationToken = default) + { + var parameters = new Dictionary{ ["id"] = entity.Id, ["measurement"] = measurement }; + return await GroupGetAsync("Metric", parameters, cancellationToken); + } } } diff --git a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs index 9eddec4..a386bc0 100644 --- a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Seq.Api.Model.Diagnostics; +using Seq.Api.Model.Inputs; namespace Seq.Api.ResourceGroups { @@ -57,5 +59,17 @@ public async Task GetIngestionLogAsync(CancellationToken cancellationTok { return await GroupGetStringAsync("IngestionLog", cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Retrieve a detailed system metric. + /// + /// A allowing the operation to be canceled. + /// The measurement to get. + /// + public async Task GetMeasurementTimeseriesAsync(string measurement, CancellationToken cancellationToken = default) + { + var parameters = new Dictionary{ ["measurement"] = measurement }; + return await GroupGetAsync("Metric", parameters, cancellationToken); + } } } diff --git a/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs b/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs new file mode 100644 index 0000000..0327347 --- /dev/null +++ b/src/Seq.Api/ResourceGroups/RunningTasksResourceGroup.cs @@ -0,0 +1,66 @@ +// 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 System.Threading; +using System.Threading.Tasks; +using Seq.Api.Model.Monitoring; +using Seq.Api.Model.Tasks; + +namespace Seq.Api.ResourceGroups +{ + /// + /// Inspect and cancel tasks running in the Seq server. + /// + public class RunningTasksResourceGroup : ApiResourceGroup + { + internal RunningTasksResourceGroup (ISeqConnection connection) + : base("RunningTasks", connection) + { + } + + /// + /// Retrieve the task with the given id; throws if the entity does not exist. + /// + /// The id of the task. + /// A allowing the operation to be canceled. + /// The task. + public async Task FindAsync(string id, CancellationToken cancellationToken = default) + { + if (id == null) throw new ArgumentNullException(nameof(id)); + return await GroupGetAsync("Item", new Dictionary { { "id", id } }, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieve all tasks running on the server. + /// + /// allowing the operation to be canceled. + /// A list containing all running tasks. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + return await GroupListAsync("Items", null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Request cancellation of a running task. The task must support cancellation; see . + /// + /// The task to cancel. + /// allowing the cancellation operation itself to be canceled. + public async Task RequestCancellationAsync(AlertStateEntity entity, CancellationToken cancellationToken = default) + { + await Client.DeleteAsync(entity, "Self", entity, cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/Seq.Api/SeqConnection.cs b/src/Seq.Api/SeqConnection.cs index f1f96ba..1710ff3 100644 --- a/src/Seq.Api/SeqConnection.cs +++ b/src/Seq.Api/SeqConnection.cs @@ -151,6 +151,11 @@ public void Dispose() /// public RolesResourceGroup Roles => new RolesResourceGroup(this); + /// + /// Perform operations on tasks running in the Seq server. + /// + public RunningTasksResourceGroup RunningTasks => new RunningTasksResourceGroup(this); + /// /// Perform operations on system settings. ///