Avoid to increment event.out conter for dropped events (#13593)

Fixes the issue #8752 in event.out counter. When a pipeline contains a drop filter the total out events counter should count only the events that reached the out stage.

This PR changes CompiledExecution.compute() interface to return the number of events that effectively reached the end of the pipeline. This change is used in WorkerLoop to update correctly the event.out metric, instead of relying on the batch's size.
This commit is contained in:
Andrea Selva 2022-01-14 15:52:06 +01:00 committed by GitHub
parent 2892964ba1
commit b6da829f4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 98 additions and 12 deletions

View file

@ -17,6 +17,7 @@
require_relative '../framework/fixture'
require_relative '../framework/settings'
require_relative '../framework/helpers'
require_relative '../services/logstash_service'
require "logstash/devutils/rspec/spec_helper"
require "stud/try"
@ -51,6 +52,52 @@ describe "Test Monitoring API" do
end
end
context "verify global event counters" do
let(:tcp_port) { random_port }
let(:sample_data) { 'Hello World!' }
let(:logstash_service) { @fixture.get_service("logstash") }
before(:each) do
logstash_service.spawn_logstash("-w", "1" , "-e", config)
logstash_service.wait_for_logstash
wait_for_port(tcp_port, 60)
send_data(tcp_port, sample_data)
end
context "when a drop filter is in the pipeline" do
let(:config) { @fixture.config("dropping_events", { :port => tcp_port } ) }
it 'expose the correct output counter' do
try(max_retry) do
# node_stats can fail if the stats subsystem isn't ready
result = logstash_service.monitoring_api.node_stats rescue nil
expect(result).not_to be_nil
expect(result["events"]).not_to be_nil
expect(result["events"]["in"]).to eq(1)
expect(result["events"]["filtered"]).to eq(1)
expect(result["events"]["out"]).to eq(0)
end
end
end
context "when a clone filter is in the pipeline" do
let(:config) { @fixture.config("cloning_events", { :port => tcp_port } ) }
it 'expose the correct output counter' do
try(max_retry) do
# node_stats can fail if the stats subsystem isn't ready
result = logstash_service.monitoring_api.node_stats rescue nil
expect(result).not_to be_nil
expect(result["events"]).not_to be_nil
expect(result["events"]["in"]).to eq(1)
expect(result["events"]["filtered"]).to eq(1)
expect(result["events"]["out"]).to eq(3)
end
end
end
end
it "can retrieve JVM stats" do
logstash_service = @fixture.get_service("logstash")
logstash_service.start_with_stdin