Skip to content

Commit

Permalink
Return statistics about forecasts as part of the job stats and usage …
Browse files Browse the repository at this point in the history
…API. (#3593)
  • Loading branch information
Stuart Cam authored and russcam committed Mar 21, 2019
1 parent 327031f commit 62d522f
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/Nest/XPack/Info/XPackUsage/XPackUsageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public class Job

[JsonProperty("model_size")]
public JobStatistics ModelSize { get; internal set; }

[JsonProperty("forecasts")]
public ForecastStatistics Forecasts { get; internal set; }
}

public class JobStatistics
Expand All @@ -202,5 +205,45 @@ public class JobStatistics
[JsonProperty("total")]
public double Total { get; internal set; }
}

public class ForecastStatistics
{
/// <summary>
/// The number of forecasts currently available for this model.
/// </summary>
[JsonProperty("total")]
public long Total { get; internal set; }

/// <summary>
/// The number of jobs that have at least one forecast.
/// </summary>
[JsonProperty("forecasted_jobs")]
public long Jobs { get; internal set; }

/// <summary>
/// Statistics about the memory usage: minimum, maximum, average and total.
/// </summary>
[JsonProperty("memory_bytes")]
public JobStatistics MemoryBytes { get; internal set; }

/// <summary>
/// Statistics about the forecast runtime in milliseconds: minimum, maximum, average and total.
/// </summary>
[JsonProperty("processing_time_ms")]
public JobStatistics ProcessingTimeMilliseconds { get; internal set; }

/// <summary>
/// Statistics about the number of forecast records: minimum, maximum, average and total.
/// </summary>
[JsonProperty("records")]
public JobStatistics Records { get; internal set; }

/// <summary>
/// Counts per forecast status.
/// </summary>
[JsonProperty("status")]
public IReadOnlyDictionary<string, long> Status { get; internal set; }
= EmptyReadOnly<string, long>.Dictionary;
}
}
}
58 changes: 57 additions & 1 deletion src/Nest/XPack/MachineLearning/Job/Config/JobStats.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Nest
{
Expand Down Expand Up @@ -49,5 +50,60 @@ public class JobStats
/// </summary>
[JsonProperty("state")]
public JobState State { get; internal set; }

/// <summary>
/// Contains job statistics if job contains a forecast.
/// </summary>
[JsonProperty("forecasts_stats")]
public JobForecastStatistics Forecasts { get; internal set; }
}

public class JobForecastStatistics
{
/// <summary>
/// The number of forecasts currently available for this model.
/// </summary>
[JsonProperty("total")]
public long Total { get; internal set; }

/// <summary>
/// Statistics about the memory usage: minimum, maximum, average and total.
/// </summary>
[JsonProperty("memory_bytes")]
public JobStatistics MemoryBytes { get; internal set; }

/// <summary>
/// Statistics about the forecast runtime in milliseconds: minimum, maximum, average and total.
/// </summary>
[JsonProperty("processing_time_ms")]
public JobStatistics ProcessingTimeMilliseconds { get; internal set; }

/// <summary>
/// Statistics about the number of forecast records: minimum, maximum, average and total.
/// </summary>
[JsonProperty("records")]
public JobStatistics Records { get; internal set; }

/// <summary>
/// Counts per forecast status.
/// </summary>
[JsonProperty("status")]
public IReadOnlyDictionary<string, long> Status { get; internal set; }
= EmptyReadOnly<string, long>.Dictionary;

public class JobStatistics
{
[JsonProperty("avg")]
public double Average { get; internal set; }

[JsonProperty("max")]
public double Maximum { get; internal set; }

[JsonProperty("min")]
public double Minimum { get; internal set; }

[JsonProperty("total")]
public double Total { get; internal set; }
}
}
}

0 comments on commit 62d522f

Please sign in to comment.