[ti_opencti] Keep expected nulls, improve error handling #8875
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Why set
keep_null: true
?While ingesting from the public demo instance of OpenCTI, I observed a large number of errors, containing the message
Processor "rename" with tag "" in pipeline \"logs-ti_opencti.indicator-0.3.4" failed with message "field [description] doesn't exist"
. Theevent.original
value showed thatdescription
key existed and had anull
value, and the pipeline did correctly handle null descriptions.There was a pipeline test example that included a null description that was processed correctly.
The GraphQL query requested the description field and received it with a null value, but Beats removed it because the
keep_null
setting defaults tofalse
. Avoiding changes between output from the CEL expression and input to the ingest pipeline seems less surprising and resolves the observed errors.Why change error handling?
The OpenCTI server may respond with an error message. For example, for an authentication/authorization error it will respond it will HTTP status code of
200
and a body as follows:The CEL expression assumed that
.data.indicators
is an array (as it is in a successful empty response). That led to an error message offailed eval: no such key: edges
and laterProcessor "rename" with tag "" in pipeline "logs-ti_opencti.indicator-0.3.4" failed with message "field [created] doesn't exist"
.The improved CEL expression handles this situation gracefully by detecting the error and capturing more information about it, and then the pipeline logic marks it as a failure without trying to apply processing steps that require a full, correct document. The indexed document will now include the following helpful information:
Checklist
changelog.yml
file.How to test this PR locally