Skip to content

Commit

Permalink
Merge branch 'beats-36876' of github.com:anil-elastic/beats into beat…
Browse files Browse the repository at this point in the history
…s-36876
  • Loading branch information
anil-elastic committed Jul 3, 2024
2 parents 7485d1f + 0eacc73 commit 4de535e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add ability to remove request trace logs from http_endpoint input. {pull}40005[40005]
- Add ability to remove request trace logs from entityanalytics input. {pull}40004[40004]
- Relax constraint on Base DN in entity analytics Active Directory provider. {pull}40054[40054]
- Enhance input state reporting for CEL evaluations that return a single error object in events. {pull}40083[40083]

*Auditbeat*

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/docs/inputs/input-cel.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ After completion of a program's execution it should return a single object with
----

<1> The `events` field must be present, but may be empty or null. If it is not empty, it must only have objects as elements.
The field should be an array, but in the case of an error condition in the CEL program it is acceptable to return a single object instead of an array; this will will be wrapped as an array for publication and an error will be logged.
The field should be an array, but in the case of an error condition in the CEL program it is acceptable to return a single object instead of an array; this will will be wrapped as an array for publication and an error will be logged. If the single object contains a key, "error", the error value will be used to update the status of the input to report to Elastic Agent. This can be used to more rapidly respond to API failures.

<2> If `cursor` is present it must be either be a single object or an array with the same length as events; each element _i_ of the `cursor` will be the details for obtaining the events at and beyond event _i_ in the `events` array. If the `cursor` is a single object it is will be the details for obtaining events after the last event in the `events` array and will only be retained on successful publication of all the events in the `events` array.

Expand Down
6 changes: 5 additions & 1 deletion x-pack/filebeat/input/cel/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,11 @@ func (i input) run(env v2.Context, src *source, cursor map[string]interface{}, p
return nil
}
log.Errorw("single event object returned by evaluation", "event", e)
env.UpdateStatus(status.Degraded, "single event object returned by evaluation")
if err, ok := e["error"]; ok {
env.UpdateStatus(status.Degraded, fmt.Sprintf("single event error object returned by evaluation: %s", mapstr.M{"error": err}))
} else {
env.UpdateStatus(status.Degraded, "single event object returned by evaluation")
}
isDegraded = true
events = []interface{}{e}
// Make sure the cursor is not updated.
Expand Down

0 comments on commit 4de535e

Please sign in to comment.