Skip to content

Commit ce63220

Browse files
authored
Support terminate processor. (#345)
* Support terminate processor. * Update the integration test for terminate processor to it check the expectation that after terminate processor no other processors should run.
1 parent d3ba405 commit ce63220

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

spec/integration/elastic_integration_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,35 @@ def path; @path; end
11341134
# end
11351135
end
11361136

1137+
describe 'with terminate processor' do
1138+
let(:pipeline_processor) {
1139+
'{
1140+
"terminate": {
1141+
"if": "ctx.error != null",
1142+
"tag": "terminated_ingest_pipeline"
1143+
}
1144+
},
1145+
{
1146+
"append": {
1147+
"field": "append_field",
1148+
"value": ["integration", "test"]
1149+
}
1150+
}'
1151+
}
1152+
1153+
it 'terminates the ingest pipeline' do
1154+
events = [LogStash::Event.new(
1155+
"message" => "Send message to pipeline which gets terminated.",
1156+
"error" => "This is intentionally placed error.",
1157+
"data_stream" => data_stream)]
1158+
1159+
subject.multi_filter(events).each do |event|
1160+
expect(event.get("[@metadata][target_ingest_pipeline]")).to include("_none")
1161+
# intentionally placed append processor to check if it is not executed after terminate processor
1162+
expect(event.get("append_field")).to be_nil
1163+
end
1164+
end
1165+
end
11371166
end
11381167

11391168
context '#multi-pipeline execution' do

src/main/java/co/elastic/logstash/filters/elasticintegration/EventProcessorBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public EventProcessorBuilder() {
122122
org.elasticsearch.ingest.common.SetProcessor.TYPE,
123123
org.elasticsearch.ingest.common.SortProcessor.TYPE,
124124
org.elasticsearch.ingest.common.SplitProcessor.TYPE,
125+
"terminate", // note: upstream constant is package-private
125126
org.elasticsearch.ingest.common.TrimProcessor.TYPE,
126127
org.elasticsearch.ingest.common.URLDecodeProcessor.TYPE,
127128
org.elasticsearch.ingest.common.UppercaseProcessor.TYPE,

0 commit comments

Comments
 (0)