Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script processor (elastic#10850)
The script processor executes Javascript code to process an event. The processor uses a pure Go implementation of ECMAScript 5.1. This can be useful in situations where one of the other processors doesn’t provide the functionality you need to filter events. The processor can be configured by embedding Javascript in your configuration file or by pointing the processor at external file(s). See the included documentation for the full details. processors: - script: type: javascript code: > function process(event) { event.Tag("js"); } For observability it can add metrics with a histogram of the execution time and a counter for the number of exceptions that occur. There is an optional timeout configuration option to the processor that will timeout the execution by interrupting the JS code. Rather than have libbeat force the inclusion of the script processor in all Beats, make each Beat opt into the processor. It is imported by the log processing Beats (filebeat, journalbeat, and winlogbeat). Benchmark Results Here's a benchmark to get a rough idea of how long it takes to process an event in the processor's runtime I updated the benchmark to test each case with and without the timeout enabled. BenchmarkBeatEventV0/Put-12 2000000 707 ns/op BenchmarkBeatEventV0/timeout_Put-12 1000000 1510 ns/op BenchmarkBeatEventV0/Object_Put_Key-12 2000000 631 ns/op BenchmarkBeatEventV0/timeout_Object_Put_Key-12 1000000 1252 ns/op BenchmarkBeatEventV0/Get-12 2000000 750 ns/op BenchmarkBeatEventV0/timeout_Get-12 1000000 1495 ns/op BenchmarkBeatEventV0/Get_Undefined_Key-12 1000000 1039 ns/op BenchmarkBeatEventV0/timeout_Get_Undefined_Key-12 1000000 2108 ns/op BenchmarkBeatEventV0/fields_get_key-12 2000000 1044 ns/op BenchmarkBeatEventV0/timeout_fields_get_key-12 1000000 2051 ns/op BenchmarkBeatEventV0/Get_@metadata-12 2000000 750 ns/op BenchmarkBeatEventV0/timeout_Get_@metadata-12 1000000 1745 ns/op BenchmarkBeatEventV0/Put_@metadata-12 1000000 1048 ns/op BenchmarkBeatEventV0/timeout_Put_@metadata-12 500000 2623 ns/op BenchmarkBeatEventV0/Delete_@metadata-12 2000000 842 ns/op BenchmarkBeatEventV0/timeout_Delete_@metadata-12 1000000 1629 ns/op BenchmarkBeatEventV0/Cancel-12 2000000 759 ns/op BenchmarkBeatEventV0/timeout_Cancel-12 1000000 1329 ns/op BenchmarkBeatEventV0/Tag-12 1000000 1189 ns/op BenchmarkBeatEventV0/timeout_Tag-12 1000000 1973 ns/op BenchmarkBeatEventV0/AppendTo-12 2000000 644 ns/op BenchmarkBeatEventV0/timeout_AppendTo-12 1000000 1347 ns/op
- Loading branch information