Skip to content

Commit

Permalink
Fix empty node stats pipelines (#17185)
Browse files Browse the repository at this point in the history
Fixed an issue where the `/_node/stats` API displayed empty pipeline metrics
when X-Pack monitoring was enabled

(cherry picked from commit 8678581)
  • Loading branch information
kaisecheng authored and logstashmachine committed Feb 28, 2025
1 parent 71127fa commit 2cb2bc4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions logstash-core/lib/logstash/api/commands/stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def report(stats, extended_stats = nil, opts = {})
:reloads => stats[:reloads],
:queue => stats[:queue],
:pipeline => {
:workers => stats[:config][:workers],
:batch_size => stats[:config][:batch_size],
:batch_delay => stats[:config][:batch_delay],
:workers => stats.dig(:config, :workers),
:batch_size => stats.dig(:config, :batch_size),
:batch_delay => stats.dig(:config, :batch_delay),
}
}
ret[:dead_letter_queue] = stats[:dlq] if stats.include?(:dlq)
Expand Down
6 changes: 6 additions & 0 deletions qa/integration/services/monitoring_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def pipeline_stats(pipeline_id)
stats_response.fetch("pipelines").fetch(pipeline_id)
end

def pipelines_stats
resp = Manticore.get("http://localhost:#{@port}/_node/stats/pipelines").body
stats_response = JSON.parse(resp)
stats_response.fetch("pipelines")
end

def event_stats
resp = Manticore.get("http://localhost:#{@port}/_node/stats").body
stats_response = JSON.parse(resp)
Expand Down
6 changes: 6 additions & 0 deletions x-pack/qa/integration/monitoring/direct_shipping_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

include_examples "record monitoring data to es"

it "gives pipelines stats" do
api = MonitoringAPI.new
stats = api.pipelines_stats
expect(stats.keys).not_to be_nil
end

after :all do
@logstash_service.stop unless @logstash_service.nil?
@elasticsearch_service.stop unless @elasticsearch_service.nil?
Expand Down

0 comments on commit 2cb2bc4

Please sign in to comment.