Skip to content

Commit 1a8724d

Browse files
authored
Add processor stats to node ingest stats (#3529)
1 parent 7546336 commit 1a8724d

File tree

3 files changed

+71
-13
lines changed

3 files changed

+71
-13
lines changed
Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,59 @@
1-
using Newtonsoft.Json;
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
56
[JsonObject]
67
public class IngestStats
78
{
8-
/// <summary>
9-
/// The total number of document ingested during the lifetime of this node
10-
/// </summary>
9+
/// <summary> The total number of document ingested during the lifetime of this node</summary>
1110
[JsonProperty("count")]
1211
public long Count { get; set; }
1312

14-
/// <summary>
15-
/// The total number of documents currently being ingested.
16-
/// </summary>
13+
/// <summary> The total number of documents currently being ingested. </summary>
1714
[JsonProperty("current")]
1815
public long Current { get; set; }
1916

20-
/// <summary>
21-
/// The total number ingest preprocessing operations failed during the lifetime of this node
22-
/// </summary>
17+
/// <summary> The total number ingest preprocessing operations failed during the lifetime of this node </summary>
2318
[JsonProperty("failed")]
2419
public long Failed { get; set; }
2520

26-
/// <summary>
27-
/// The total time spent on ingest preprocessing documents during the lifetime of this node
28-
/// </summary>
21+
/// <summary> The total time spent on ingest preprocessing documents during the lifetime of this node </summary>
2922
[JsonProperty("time_in_millis")]
3023
public long TimeInMilliseconds { get; set; }
24+
25+
[JsonProperty("processors")]
26+
public IReadOnlyCollection<KeyedProcessorStats> Processors { get; internal set; } =
27+
EmptyReadOnly<KeyedProcessorStats>.Collection;
28+
}
29+
30+
[JsonConverter(typeof(KeyValueJsonConverter<KeyedProcessorStats, ProcessStats>))]
31+
public class KeyedProcessorStats
32+
{
33+
/// <summary> The type of the processor </summary>
34+
public string Type { get; set; }
35+
36+
/// <summary>The statistics for this processor</summary>
37+
public ProcessStats Statistics { get; set; }
38+
}
39+
40+
[JsonObject]
41+
public class ProcessorStats
42+
{
43+
/// <summary> The total number of document ingested during the lifetime of this node </summary>
44+
[JsonProperty("count")]
45+
public long Count { get; internal set; }
46+
47+
/// <summary> The total number of documents currently being ingested. </summary>
48+
[JsonProperty("current")]
49+
public long Current { get; internal set; }
50+
51+
/// <summary> The total number ingest preprocessing operations failed during the lifetime of this node </summary>
52+
[JsonProperty("failed")]
53+
public long Failed { get; internal set; }
54+
55+
/// <summary> The total time spent on ingest preprocessing documents during the lifetime of this node </summary>
56+
[JsonProperty("time_in_millis")]
57+
public long TimeInMilliseconds { get; internal set; }
3158
}
3259
}

src/Tests/Tests.Core/ManagedElasticsearch/NodeSeeders/DefaultSeeder.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class DefaultSeeder
1717
public const string ProjectsAliasName = "projects-alias";
1818
public const string TestsIndexTemplateName = "nest_tests";
1919

20+
public const string PipelineName = "nest-pipeline";
21+
2022
private readonly IIndexSettings _defaultIndexSettings = new IndexSettings()
2123
{
2224
NumberOfShards = 2,
@@ -63,6 +65,7 @@ private async Task SeedNodeAsync()
6365
// Ensure a clean slate by deleting everything regardless of whether they may already exist
6466
await DeleteIndicesAndTemplatesAsync();
6567
await ClusterSettingsAsync();
68+
await PutPipeline();
6669
// and now recreate everything
6770
await CreateIndicesAndSeedIndexDataAsync();
6871
}
@@ -89,6 +92,20 @@ public async Task ClusterSettingsAsync()
8992
putSettingsResponse.ShouldBeValid();
9093
}
9194

95+
public async Task PutPipeline()
96+
{
97+
if (TestConfiguration.Instance.InRange("<6.1.0")) return;
98+
99+
var putProcessors = await Client.PutPipelineAsync(PipelineName, pi => pi
100+
.Description("A pipeline registered by the NEST test framework")
101+
.Processors(pp => pp
102+
.Set<Project>(s => s.Field(p => p.Metadata).Value(new { x = "y" }))
103+
)
104+
);
105+
putProcessors.ShouldBeValid();
106+
}
107+
108+
92109
public async Task DeleteIndicesAndTemplatesAsync()
93110
{
94111
var tasks = new Task[]

src/Tests/Tests/Cluster/NodesStats/NodesStatsApiTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Nest;
66
using Tests.Core.Extensions;
77
using Tests.Core.ManagedElasticsearch.Clusters;
8+
using Tests.Core.ManagedElasticsearch.NodeSeeders;
89
using Tests.Domain;
910
using Tests.Framework;
1011
using Tests.Framework.Integration;
@@ -73,6 +74,19 @@ protected void Assert(NodeIngestStats nodeIngestStats)
7374
nodeIngestStats.Should().NotBeNull();
7475
nodeIngestStats.Total.Should().NotBeNull();
7576
nodeIngestStats.Pipelines.Should().NotBeNull();
77+
nodeIngestStats.Pipelines.Should().ContainKey(DefaultSeeder.PipelineName);
78+
79+
var pipelineStats = nodeIngestStats.Pipelines[DefaultSeeder.PipelineName];
80+
81+
pipelineStats.Should().NotBeNull();
82+
pipelineStats.Processors.Should().NotBeNull().And.HaveCount(1);
83+
84+
var processorStats = pipelineStats.Processors.First();
85+
86+
processorStats.Type.Should().Be("set");
87+
processorStats.Statistics.Should().NotBeNull();
88+
89+
7690
}
7791

7892
protected void Assert(IReadOnlyDictionary<string, AdaptiveSelectionStats> adaptiveSelectionStats) =>

0 commit comments

Comments
 (0)