Skip to content

Commit e48f1b2

Browse files
kaisechengmergify[bot]
authored andcommitted
Fix empty node stats pipelines (#17185)
Fixed an issue where the `/_node/stats` API displayed empty pipeline metrics when X-Pack monitoring was enabled (cherry picked from commit 8678581)
1 parent 18772dd commit e48f1b2

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

logstash-core/lib/logstash/api/commands/stats.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ def report(stats, extended_stats = nil, opts = {})
185185
:reloads => stats[:reloads],
186186
:queue => stats[:queue],
187187
:pipeline => {
188-
:workers => stats[:config][:workers],
189-
:batch_size => stats[:config][:batch_size],
190-
:batch_delay => stats[:config][:batch_delay],
188+
:workers => stats.dig(:config, :workers),
189+
:batch_size => stats.dig(:config, :batch_size),
190+
:batch_delay => stats.dig(:config, :batch_delay),
191191
}
192192
}
193193
ret[:dead_letter_queue] = stats[:dlq] if stats.include?(:dlq)

qa/integration/services/monitoring_api.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ def pipeline_stats(pipeline_id)
3131
stats_response.fetch("pipelines").fetch(pipeline_id)
3232
end
3333

34+
def pipelines_stats
35+
resp = Manticore.get("http://localhost:#{@port}/_node/stats/pipelines").body
36+
stats_response = JSON.parse(resp)
37+
stats_response.fetch("pipelines")
38+
end
39+
3440
def event_stats
3541
resp = Manticore.get("http://localhost:#{@port}/_node/stats").body
3642
stats_response = JSON.parse(resp)

x-pack/qa/integration/monitoring/direct_shipping_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030

3131
include_examples "record monitoring data to es"
3232

33+
it "gives pipelines stats" do
34+
api = MonitoringAPI.new
35+
stats = api.pipelines_stats
36+
expect(stats.keys).not_to be_nil
37+
end
38+
3339
after :all do
3440
@logstash_service.stop unless @logstash_service.nil?
3541
@elasticsearch_service.stop unless @elasticsearch_service.nil?

0 commit comments

Comments
 (0)