Skip to content

Conversation

mashhurs
Copy link
Collaborator

Registers terminate processor to the support list.

Copy link

mergify bot commented Jul 14, 2025

This pull request does not have a backport label. Could you fix it @mashhurs? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

'{
"terminate": {
"if": "ctx.error != null",
"tag": "terminated_ingest_pipeline"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wished this tag be available in _ingest_document so that I can expect(event.get("[tag]")).to eql? "terminated_ingest_pipeline" but no tag exists.

org.elasticsearch.ingest.common.SetProcessor.TYPE,
org.elasticsearch.ingest.common.SortProcessor.TYPE,
org.elasticsearch.ingest.common.SplitProcessor.TYPE,
"terminate", // note: upstream constant is package-private
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mashhurs mashhurs added backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches labels Jul 15, 2025
@mashhurs mashhurs requested review from donoghuc and yaauie July 15, 2025 04:55
"data_stream" => data_stream)]

subject.multi_filter(events).each do |event|
expect(event.get("[@metadata][target_ingest_pipeline]")).to include("_none")
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand what exactly this assertion proves WRT the termination? Looks like with "if": "ctx.error != null" the terminate will trigger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After plugin successfully executes the pipeline, it let's know (set the [@metadata][target_ingest_pipeline] to _none) es-output to avoid ingest pipeline execution in Elasticsearch side.

what exactly this assertion proves WRT the termination?

Yeah, this one I tried to highlight here that terminate processor doesn't attach any specific fields we can validate (it seems tag is for debug purpose). I have updated the integration test which adds append processor after terminate and validates to make sure append processor didn't execute.
Correspond ES query as an integration test would like this:

POST /_ingest/pipeline/_simulate
{
  "pipeline" :
  {
    "processors": [
      {
        "terminate": {
          "if": "ctx.error != null",
          "tag": "terminated_pipeline"
        }
      },
      {
        "append": {
          "field": "message",
          "value": "my message value"
        }
      }
    ]
  },
  "docs": [
    {
      "_index": "index",
      "_id": "id1",
      "_source": {
        "foo": "bar",
        "error": "some exception"
      }
    },
    {
      "_index": "index",
      "_id": "id2",
      "_source": {
        "foo": "rab"
      }
    }
  ]
}

In the result, we can see id1 will not have message since pipeline was terminated by terminate processor:

{
  "docs": [
    {
      "doc": {
        "_index": "index",
        "_version": "-3",
        "_id": "id1",
        "_source": {
          "error": "some exception",
          "foo": "bar"
        },
        "_ingest": {
          "timestamp": "2025-07-15T23:56:43.427866851Z"
        }
      }
    },
    {
      "doc": {
        "_index": "index",
        "_version": "-3",
        "_id": "id2",
        "_source": {
          "message": [
            "my message value"
          ],
          "foo": "rab"
        },
        "_ingest": {
          "timestamp": "2025-07-15T23:56:43.427882279Z"
        }
      }
    }
  ]
}

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! That is very helpful. Love that idea!

…xpectation that after terminate processor no other processors should run.
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Member

@donoghuc donoghuc left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed breakdown. That is very helpful. Appreciate the extra context.

@mashhurs mashhurs linked an issue Jul 16, 2025 that may be closed by this pull request
@mashhurs
Copy link
Collaborator Author

Just FYI: terminate was introduced in ES 8.16 versions, so worth to backport to all active branches.

@mashhurs mashhurs merged commit ce63220 into elastic:main Jul 16, 2025
4 checks passed
@mashhurs mashhurs deleted the support-terminate-processor branch July 16, 2025 15:25
Copy link
Contributor

@Mergifyio backport 8.17 8.18 8.19 9.0 9.1

Copy link

mergify bot commented Jul 16, 2025

backport 8.17 8.18 8.19 9.0 9.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 16, 2025
* Support terminate processor.

* Update the integration test for terminate processor to it check the expectation that after terminate processor no other processors should run.

(cherry picked from commit ce63220)
mergify bot pushed a commit that referenced this pull request Jul 16, 2025
* Support terminate processor.

* Update the integration test for terminate processor to it check the expectation that after terminate processor no other processors should run.

(cherry picked from commit ce63220)
mergify bot pushed a commit that referenced this pull request Jul 16, 2025
* Support terminate processor.

* Update the integration test for terminate processor to it check the expectation that after terminate processor no other processors should run.

(cherry picked from commit ce63220)
mergify bot pushed a commit that referenced this pull request Jul 16, 2025
* Support terminate processor.

* Update the integration test for terminate processor to it check the expectation that after terminate processor no other processors should run.

(cherry picked from commit ce63220)
mergify bot pushed a commit that referenced this pull request Jul 16, 2025
* Support terminate processor.

* Update the integration test for terminate processor to it check the expectation that after terminate processor no other processors should run.

(cherry picked from commit ce63220)
mashhurs added a commit that referenced this pull request Jul 16, 2025
* 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.

(cherry picked from commit ce63220)

* Add changelog and version bump.

---------

Co-authored-by: Mashhur <[email protected]>
Co-authored-by: Mashhur <[email protected]>
mashhurs added a commit that referenced this pull request Jul 16, 2025
* 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.

(cherry picked from commit ce63220)

* Add changelog and version bump.

---------

Co-authored-by: Mashhur <[email protected]>
Co-authored-by: Mashhur <[email protected]>
mashhurs added a commit that referenced this pull request Jul 16, 2025
* 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.

(cherry picked from commit ce63220)

* Add changelog and bump version.

---------

Co-authored-by: Mashhur <[email protected]>
Co-authored-by: Mashhur <[email protected]>
mashhurs added a commit that referenced this pull request Jul 16, 2025
* 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.

(cherry picked from commit ce63220)

* Add changelog and bump version.

---------

Co-authored-by: Mashhur <[email protected]>
Co-authored-by: Mashhur <[email protected]>
mashhurs added a commit that referenced this pull request Jul 16, 2025
* 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.

(cherry picked from commit ce63220)

* Add changelog and version bump.

---------

Co-authored-by: Mashhur <[email protected]>
Co-authored-by: Mashhur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Evaluate terminate processor

3 participants