Skip to content

Commit 62d522f

Browse files
Stuart Camrusscam
Stuart Cam
authored andcommitted
Return statistics about forecasts as part of the job stats and usage API. (#3593)
1 parent 327031f commit 62d522f

File tree

2 files changed

+100
-1
lines changed

2 files changed

+100
-1
lines changed

src/Nest/XPack/Info/XPackUsage/XPackUsageResponse.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ public class Job
186186

187187
[JsonProperty("model_size")]
188188
public JobStatistics ModelSize { get; internal set; }
189+
190+
[JsonProperty("forecasts")]
191+
public ForecastStatistics Forecasts { get; internal set; }
189192
}
190193

191194
public class JobStatistics
@@ -202,5 +205,45 @@ public class JobStatistics
202205
[JsonProperty("total")]
203206
public double Total { get; internal set; }
204207
}
208+
209+
public class ForecastStatistics
210+
{
211+
/// <summary>
212+
/// The number of forecasts currently available for this model.
213+
/// </summary>
214+
[JsonProperty("total")]
215+
public long Total { get; internal set; }
216+
217+
/// <summary>
218+
/// The number of jobs that have at least one forecast.
219+
/// </summary>
220+
[JsonProperty("forecasted_jobs")]
221+
public long Jobs { get; internal set; }
222+
223+
/// <summary>
224+
/// Statistics about the memory usage: minimum, maximum, average and total.
225+
/// </summary>
226+
[JsonProperty("memory_bytes")]
227+
public JobStatistics MemoryBytes { get; internal set; }
228+
229+
/// <summary>
230+
/// Statistics about the forecast runtime in milliseconds: minimum, maximum, average and total.
231+
/// </summary>
232+
[JsonProperty("processing_time_ms")]
233+
public JobStatistics ProcessingTimeMilliseconds { get; internal set; }
234+
235+
/// <summary>
236+
/// Statistics about the number of forecast records: minimum, maximum, average and total.
237+
/// </summary>
238+
[JsonProperty("records")]
239+
public JobStatistics Records { get; internal set; }
240+
241+
/// <summary>
242+
/// Counts per forecast status.
243+
/// </summary>
244+
[JsonProperty("status")]
245+
public IReadOnlyDictionary<string, long> Status { get; internal set; }
246+
= EmptyReadOnly<string, long>.Dictionary;
247+
}
205248
}
206249
}

src/Nest/XPack/MachineLearning/Job/Config/JobStats.cs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json;
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
@@ -49,5 +50,60 @@ public class JobStats
4950
/// </summary>
5051
[JsonProperty("state")]
5152
public JobState State { get; internal set; }
53+
54+
/// <summary>
55+
/// Contains job statistics if job contains a forecast.
56+
/// </summary>
57+
[JsonProperty("forecasts_stats")]
58+
public JobForecastStatistics Forecasts { get; internal set; }
59+
}
60+
61+
public class JobForecastStatistics
62+
{
63+
/// <summary>
64+
/// The number of forecasts currently available for this model.
65+
/// </summary>
66+
[JsonProperty("total")]
67+
public long Total { get; internal set; }
68+
69+
/// <summary>
70+
/// Statistics about the memory usage: minimum, maximum, average and total.
71+
/// </summary>
72+
[JsonProperty("memory_bytes")]
73+
public JobStatistics MemoryBytes { get; internal set; }
74+
75+
/// <summary>
76+
/// Statistics about the forecast runtime in milliseconds: minimum, maximum, average and total.
77+
/// </summary>
78+
[JsonProperty("processing_time_ms")]
79+
public JobStatistics ProcessingTimeMilliseconds { get; internal set; }
80+
81+
/// <summary>
82+
/// Statistics about the number of forecast records: minimum, maximum, average and total.
83+
/// </summary>
84+
[JsonProperty("records")]
85+
public JobStatistics Records { get; internal set; }
86+
87+
/// <summary>
88+
/// Counts per forecast status.
89+
/// </summary>
90+
[JsonProperty("status")]
91+
public IReadOnlyDictionary<string, long> Status { get; internal set; }
92+
= EmptyReadOnly<string, long>.Dictionary;
93+
94+
public class JobStatistics
95+
{
96+
[JsonProperty("avg")]
97+
public double Average { get; internal set; }
98+
99+
[JsonProperty("max")]
100+
public double Maximum { get; internal set; }
101+
102+
[JsonProperty("min")]
103+
public double Minimum { get; internal set; }
104+
105+
[JsonProperty("total")]
106+
public double Total { get; internal set; }
107+
}
52108
}
53109
}

0 commit comments

Comments
 (0)