Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty node stats pipelines #17185

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the bug before was indexing a nil class? In the case we dont have data here should we remove nils from the map? Should we default to an empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it was nil. All other fields in this pipeline are not showing any meaningful data, it only gives empty array or null. This monitoring feature is deprecated for years. I think we have good enough reason to not set a default value here and just show null

: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 @@ -31,6 +31,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