Skip to content

Commit 8678581

Browse files
authored
Fix empty node stats pipelines (#17185)
Fixed an issue where the `/_node/stats` API displayed empty pipeline metrics when X-Pack monitoring was enabled
1 parent a4cf2bc commit 8678581

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Diff for: logstash-core/lib/logstash/api/commands/stats.rb

+3-3
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)

Diff for: qa/integration/services/monitoring_api.rb

+6
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)

Diff for: x-pack/qa/integration/monitoring/direct_shipping_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131

3232
include_examples "record monitoring data to es"
3333

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

0 commit comments

Comments
 (0)