Skip to content

Commit b03ed68

Browse files
committed
Update to the latest Seq 2020.1 API version (breaking changes, here)
* `SeqApiClient` now accepts `application/vnd.datalust.seq.v8+json`, the media type indicating 2020.1 API support * `AppInstanceEntity.InputSignalExpression` renamed to `StreamedSignalExpression` to avoid confusion with _inputs_ * `AppInstanceEntity.InputSettings` added, to support filtering, property tagging, etc. * `AppInstanceEntity.Metrics` split into `ProcessMetrics`, `InputMetrics`, `DiagnosticInputMetrics` and `OutputMetrics` (with corresponding split of `AppInstanceMetricsPart`) * `RunningTaskPart` moved from _Seq.Api.Model.Diagnostics_ to _RunningTasks_ * `Entity` carries `ExtensionData` to ease backwards compatibility on the server-side * `ApiKeyEntity.InputFilter`, `MinimumLevel`, `UseServerTimestamps` and `AppliedProperties` moved to `ApiKeyEntity.InputSettings` * New `SettingName` entries for various OpenID Connect settings, `AuthenticationProvider`, `AutomaticallyProvisionAuthenticatedUsers`, and `AzureADAuthority`; some obsolete settings removed/marked * `SignalFilterPart` renamed to `DescriptiveFilterPart`, to clarify its use across the API and not only with signals * `SeqConnection.RunningTasks` added to support diagnostics and task cancellation * `UserEntity` now exposes `AuthenticationProvider` and `AuthenticationProviderUniqueIdentifier` * `ApiKeysResourceGroup`, `AppInstancesResourceGroup` and `DiagnosticsResourceGroup` now expose `GetMeasurementTimeseriesAsync()` for 24-hr metric histograms
1 parent fad043d commit b03ed68

21 files changed

+375
-115
lines changed

src/Seq.Api/Client/SeqApiClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SeqApiClient : IDisposable
4242
// Future versions of Seq may not completely support v1 features, however
4343
// providing this as an Accept header will ensure what compatibility is available
4444
// can be utilized.
45-
const string SeqApiV7MediaType = "application/vnd.datalust.seq.v7+json";
45+
const string SeqApiV8MediaType = "application/vnd.datalust.seq.v8+json";
4646

4747
readonly CookieContainer _cookies = new CookieContainer();
4848
readonly JsonSerializer _serializer = JsonSerializer.Create(
@@ -89,7 +89,7 @@ public SeqApiClient(string serverUrl, string apiKey = null, Action<HttpClientHan
8989
baseAddress += "/";
9090

9191
HttpClient = new HttpClient(handler) { BaseAddress = new Uri(baseAddress) };
92-
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV7MediaType));
92+
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(SeqApiV8MediaType));
9393

9494
if (_apiKey != null)
9595
HttpClient.DefaultRequestHeaders.Add("X-Seq-ApiKey", _apiKey);

src/Seq.Api/Model/AppInstances/AppInstanceEntity.cs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Collections.Generic;
1717
using Newtonsoft.Json;
1818
using Seq.Api.Model.Apps;
19+
using Seq.Api.Model.Inputs;
1920
using Seq.Api.Model.Signals;
2021
using Seq.Api.ResourceGroups;
2122

@@ -38,7 +39,11 @@ public AppInstanceEntity()
3839
InvocationOverridableSettings = new List<string>();
3940
InvocationOverridableSettingDefinitions = new List<AppSettingPart>();
4041
EventsPerSuppressionWindow = 1;
41-
Metrics = new AppInstanceMetricsPart();
42+
ProcessMetrics = new AppInstanceProcessMetricsPart();
43+
InputSettings = new InputSettingsPart();
44+
InputMetrics = new InputMetricsPart();
45+
DiagnosticInputMetrics = new InputMetricsPart();
46+
OutputMetrics = new AppInstanceOutputMetricsPart();
4247
}
4348

4449
/// <summary>
@@ -90,7 +95,7 @@ public AppInstanceEntity()
9095
/// The signal expression describing which events will be sent to the app; if <c>null</c>,
9196
/// all events will reach the app.
9297
/// </summary>
93-
public SignalExpressionPart InputSignalExpression { get; set; }
98+
public SignalExpressionPart StreamedSignalExpression { get; set; }
9499

95100
/// <summary>
96101
/// If a value is specified, events will be buffered to disk and sorted by timestamp-order
@@ -113,22 +118,46 @@ public AppInstanceEntity()
113118
public int EventsPerSuppressionWindow { get; set; }
114119

115120
/// <summary>
116-
/// Metrics describing the state and activity of the app.
121+
/// Settings that control how events are ingested through the app.
117122
/// </summary>
118123
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
119-
public AppInstanceMetricsPart Metrics { get; set; }
124+
public InputSettingsPart InputSettings { get; set; }
120125

126+
/// <summary>
127+
/// Metrics describing the state and activity of the app process.
128+
/// </summary>
129+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
130+
public AppInstanceProcessMetricsPart ProcessMetrics { get; set; }
131+
132+
/// <summary>
133+
/// Information about ingestion activity through this app.
134+
/// </summary>
135+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
136+
public InputMetricsPart InputMetrics { get; set; }
137+
138+
/// <summary>
139+
/// Information about the app's diagnostic input.
140+
/// </summary>
141+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
142+
public InputMetricsPart DiagnosticInputMetrics { get; set; }
143+
144+
/// <summary>
145+
/// Information about events output through the app.
146+
/// </summary>
147+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
148+
public AppInstanceOutputMetricsPart OutputMetrics { get; set; }
149+
121150
/// <summary>
122151
/// Obsolete.
123152
/// </summary>
124-
[Obsolete("Use !AcceptStreamedEvents instead. This field will be removed in Seq 6.0.")]
153+
[Obsolete("Use !AcceptStreamedEvents instead.")]
125154
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
126155
public bool? IsManualInputOnly { get; set; }
127156

128157
/// <summary>
129158
/// Obsolete.
130159
/// </summary>
131-
[Obsolete("Use !AcceptDirectInvocation instead. This field will be removed in Seq 6.0.")]
160+
[Obsolete("Use !AcceptDirectInvocation instead.")]
132161
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
133162
public bool? DisallowManualInput { get; set; }
134163
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Seq.Api.Model.AppInstances
2+
{
3+
/// <summary>
4+
/// Describes the events reaching being output from Seq through the app.
5+
/// </summary>
6+
public class AppInstanceOutputMetricsPart
7+
{
8+
/// <summary>
9+
/// The number of events per minute sent from Seq to the app. Includes streamed events (if enabled),
10+
/// manual invocations, and alert notifications. There may be some delay between dispatching an event, and
11+
/// it being processed by the app.
12+
/// </summary>
13+
public int DispatchedEventsPerMinute { get; set; }
14+
}
15+
}

src/Seq.Api/Model/AppInstances/AppInstanceMetricsPart.cs renamed to src/Seq.Api/Model/AppInstances/AppInstanceProcessMetricsPart.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,14 @@
1515
namespace Seq.Api.Model.AppInstances
1616
{
1717
/// <summary>
18-
/// Metrics describing an <see cref="AppInstanceEntity"/>.
18+
/// Metrics describing the running server-side process for an <see cref="AppInstanceEntity"/>.
1919
/// </summary>
20-
public class AppInstanceMetricsPart
20+
public class AppInstanceProcessMetricsPart
2121
{
22-
/// <summary>
23-
/// The number of events that reached the app in the past minute.
24-
/// </summary>
25-
public int ReceivedEventsPerMinute { get; set; }
26-
27-
/// <summary>
28-
/// The number of diagnostic events raised by the app in the past minute.
29-
/// </summary>
30-
/// <remarks>This does not include the events received by an input app.</remarks>
31-
public int EmittedEventsPerMinute { get; set; }
32-
3322
/// <summary>
3423
/// The size, in bytes, of the app process working set.
3524
/// </summary>
36-
public long ProcessWorkingSetBytes { get; set; }
25+
public long WorkingSetBytes { get; set; }
3726

3827
/// <summary>
3928
/// If the app process is running, <c>true</c>; otherwise, <c>false</c>.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright © Datalust and contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System;
16+
17+
namespace Seq.Api.Model.Diagnostics
18+
{
19+
/// <summary>
20+
/// A histogram presenting a measurement taken at equal intervals.
21+
/// </summary>
22+
public class MeasurementTimeseriesPart
23+
{
24+
/// <summary>
25+
/// The point in time from which measurement begins.
26+
/// </summary>
27+
public DateTime MeasuredFrom { get; set; }
28+
29+
/// <summary>
30+
/// The interval at which the measurement is taken.
31+
/// </summary>
32+
public ulong MeasurementIntervalMilliseconds { get; set; }
33+
34+
/// <summary>
35+
/// The measurements at each interval, beginning with <see cref="MeasuredFrom"/>.
36+
/// </summary>
37+
public long[] Measurements { get; set; }
38+
}
39+
}

src/Seq.Api/Model/Diagnostics/ServerMetricsEntity.cs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class ServerMetricsEntity : Entity
2727
/// </summary>
2828
public ServerMetricsEntity()
2929
{
30-
RunningTasks = new List<RunningTaskPart>();
3130
}
3231

3332
/// <summary>
@@ -40,16 +39,6 @@ public ServerMetricsEntity()
4039
/// </summary>
4140
public int EventStoreEventsCached { get; set; }
4241

43-
/// <summary>
44-
/// The oldest on-disk extent currently stored.
45-
/// </summary>
46-
public DateTime? EventStoreFirstExtentRangeStartUtc { get; set; }
47-
48-
/// <summary>
49-
/// The most recent on-disk extent currently stored.
50-
/// </summary>
51-
public DateTime? EventStoreLastExtentRangeEndUtc { get; set; }
52-
5342
/// <summary>
5443
/// Bytes of free space remaining on the disk used for event storage.
5544
/// </summary>
@@ -58,27 +47,27 @@ public ServerMetricsEntity()
5847
/// <summary>
5948
/// The number of events that arrived at the ingestion endpoint in the past minute.
6049
/// </summary>
61-
public int EndpointArrivalsPerMinute { get; set; }
50+
public int InputArrivedEventsPerMinute { get; set; }
6251

6352
/// <summary>
6453
/// The number of events ingested in the past minute.
6554
/// </summary>
66-
public int EndpointInfluxPerMinute { get; set; }
55+
public int InputIngestedEventsPerMinute { get; set; }
6756

6857
/// <summary>
6958
/// The number of bytes of raw JSON event data ingested in the past minute (approximate).
7059
/// </summary>
71-
public long EndpointIngestedBytesPerMinute { get; set; }
60+
public long InputIngestedBytesPerMinute { get; set; }
7261

7362
/// <summary>
7463
/// The number of invalid event payloads seen in the past minute.
7564
/// </summary>
76-
public int EndpointInvalidPayloadsPerMinute { get; set; }
65+
public int InvalidPayloadsPerMinute { get; set; }
7766

7867
/// <summary>
7968
/// The number of unauthorized event payloads seen in the past minute.
8069
/// </summary>
81-
public int EndpointUnauthorizedPayloadsPerMinute { get; set; }
70+
public int HttpUnauthorizedPayloadsPerMinute { get; set; }
8271

8372
/// <summary>
8473
/// The length of time for which the Seq server process has been running.
@@ -95,26 +84,11 @@ public ServerMetricsEntity()
9584
/// </summary>
9685
public int ProcessThreads { get; set; }
9786

98-
/// <summary>
99-
/// The number of thread pool user threads available.
100-
/// </summary>
101-
public int ProcessThreadPoolUserThreadsAvailable { get; set; }
102-
103-
/// <summary>
104-
/// The number of async I/O thread pool threads available.
105-
/// </summary>
106-
public int ProcessThreadPoolIocpThreadsAvailable { get; set; }
107-
10887
/// <summary>
10988
/// The proportion of system physical memory that is currently allocated.
11089
/// </summary>
11190
public double SystemMemoryUtilization { get; set; }
11291

113-
/// <summary>
114-
/// Tasks running in the Seq server.
115-
/// </summary>
116-
public List<RunningTaskPart> RunningTasks { get; set; }
117-
11892
/// <summary>
11993
/// The number of SQL-style queries executed in the past minute.
12094
/// </summary>
@@ -129,10 +103,5 @@ public ServerMetricsEntity()
129103
/// The number of cached SQL query time slices invalidated in the past minute.
130104
/// </summary>
131105
public int QueryCacheInvalidationsPerMinute { get; set; }
132-
133-
/// <summary>
134-
/// The number of active sessions reading from or writing to Seq's internal metadata store.
135-
/// </summary>
136-
public int DocumentStoreActiveSessions { get; set; }
137106
}
138107
}

src/Seq.Api/Model/Entity.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System;
16+
using System.Collections.Generic;
17+
using Newtonsoft.Json;
18+
using Newtonsoft.Json.Linq;
19+
1520
namespace Seq.Api.Model
1621
{
1722
/// <summary>
@@ -41,5 +46,12 @@ protected Entity()
4146
/// was instantiated locally and not received from the API.
4247
/// </summary>
4348
public LinkCollection Links { get; set; }
49+
50+
/// <summary>
51+
/// Facilitates backwards compatibility in the Seq server. Should not be used by consumers/clients.
52+
/// </summary>
53+
[JsonExtensionData, JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
54+
[Obsolete("Facilitates backwards compatibility in the Seq server. Should not be used by consumers/clients.")]
55+
public Dictionary<string, JToken> ExtensionData { get; set; }
4456
}
4557
}

src/Seq.Api/Model/Inputs/ApiKeyEntity.cs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
using System.Collections.Generic;
1616
using Newtonsoft.Json;
17-
using Seq.Api.Model.LogEvents;
1817
using Seq.Api.Model.Security;
19-
using Seq.Api.Model.Signals;
2018

2119
namespace Seq.Api.Model.Inputs
2220
{
@@ -33,10 +31,10 @@ public class ApiKeyEntity : Entity
3331
public string Title { get; set; }
3432

3533
/// <summary>
36-
/// The API key token. API keys generated for versions of Seq prior to 5.0 will expose this value. From 5.0 onwards,
37-
/// <see cref="Token"/> can be specified explicitly when creating an API key, but is not readable once the API key is created.
38-
/// Leaving the token blank will cause the server to generate a cryptographically random API key token. After creation, the first
39-
/// few characters of the token will be readable from <see cref="TokenPrefix"/>, but because only a cryptographically-secure
34+
/// The API key token. <see cref="Token"/> can be specified explicitly when creating an API key, but is not
35+
/// readable once the API key is created. Leaving the token blank will cause the server to generate a
36+
/// cryptographically random API key token. After creation, the first few (additional, redundant) characters
37+
/// of the token will be readable from <see cref="TokenPrefix"/>, but because only a cryptographically-secure
4038
/// hash of the token is stored internally, the token itself cannot be retrieved.
4139
/// </summary>
4240
public string Token { get; set; }
@@ -47,31 +45,12 @@ public class ApiKeyEntity : Entity
4745
public string TokenPrefix { get; set; }
4846

4947
/// <summary>
50-
/// Properties that will be automatically added to all events ingested using the key. These will override any properties with
51-
/// the same names already present on the event.
48+
/// Settings that control how events are ingested through the API key.
5249
/// </summary>
53-
public List<InputAppliedPropertyPart> AppliedProperties { get; set; } = new List<InputAppliedPropertyPart>();
50+
public InputSettingsPart InputSettings { get; set; } = new InputSettingsPart();
5451

5552
/// <summary>
56-
/// A filter that selects events to ingest. If <c>null</c>, all events received using the key will be ingested.
57-
/// </summary>
58-
public SignalFilterPart InputFilter { get; set; } = new SignalFilterPart();
59-
60-
/// <summary>
61-
/// A minimum level at which events received using the key will be ingested. The level hierarchy understood by Seq is fuzzy
62-
/// enough to handle most common leveling schemes. This value will be provided to callers so that they can dynamically
63-
/// filter events client-side, if supported.
64-
/// </summary>
65-
public LogEventLevel? MinimumLevel { get; set; }
66-
67-
/// <summary>
68-
/// If <c>true</c>, timestamps already present on the events will be ignored, and server timestamps used instead. This is not
69-
/// recommended for most use cases.
70-
/// </summary>
71-
public bool UseServerTimestamps { get; set; }
72-
73-
/// <summary>
74-
/// If <c>true</c>, the key is the built-in (tokenless) API key.
53+
/// If <c>true</c>, the key is the built-in (tokenless) API key representing unauthenticated HTTP ingestion.
7554
/// </summary>
7655
public bool IsDefault { get; set; }
7756

@@ -90,6 +69,6 @@ public class ApiKeyEntity : Entity
9069
/// Information about the ingestion activity using this API key.
9170
/// </summary>
9271
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
93-
public ApiKeyMetricsPart Metrics { get; set; } = new ApiKeyMetricsPart();
72+
public InputMetricsPart InputMetrics { get; set; } = new InputMetricsPart();
9473
}
9574
}

0 commit comments

Comments
 (0)