107 Commits

Author SHA1 Message Date
Ryan Ernst
8734540345
Ensure map keys cannot be self referencing ()
This commit improves self reference checking to map keys, as well as
adds it to ingest script processing.
2018-10-17 15:16:13 -07:00
Armin Braun
0ba1855740
INGEST: Tests for Drop Processor ()
* INGEST: Tests for Drop Processor

* UT for behavior of dropped callback
and drop processor
   * Moved drop processor to `server`
project to enable this test
* Simple IT
* Relates 
2018-09-25 19:29:22 +02:00
Jake Landis
e37e5dfc04
ingest: support simulate with verbose for pipeline processor ()
* ingest: support simulate with verbose for pipeline processor

This change better supports the use of simulate?verbose with the
pipeline processor. Prior to this change any pipeline processors
executed with simulate?verbose would not show all intermediate 
processors for the inner pipelines.

This changes also moves the PipelineProcess and TrackingResultProcessor
classes to enable instance checks and to avoid overly public classes.
As well this updates the error message for when cycles are detected
in pipelines calling other pipelines.
2018-09-20 08:33:07 -05:00
Armin Braun
46774098d9
INGEST: Implement Drop Processor ()
* INGEST: Implement Drop Processor
* Adjust Processor API
* Implement Drop Processor
* Closes 
2018-09-05 14:25:29 +02:00
Armin Braun
cc4d7059bf
Ingest: Add conditional per processor ()
* Ingest: Add conditional per processor
* closes 
2018-08-30 03:46:39 +02:00
Armin Braun
f690b492e7
INGEST: Add Pipeline Processor ()
* INGEST: Add Pipeline Processor

* Adds Processor capable of invoking other pipelines
* Closes 
2018-08-29 11:03:10 +02:00
Jake Landis
79b507dbf5
ingest: Introduce the dissect processor ()
* ingest: Introduce the dissect processor

The ingest node dissect processor is an alternative to Grok
to split a string based on a pattern. Dissect differs from
Grok such that regular expressions are not used to split the
string.

Dissect can be used to parse a source text field with a
simpler pattern, and is often faster the Grok for basic string
parsing. This processor uses the dissect library which
does most of the work.
2018-08-28 07:11:20 -07:00
Armin Braun
cf7489899a
INGEST: Clean up Java8 Stream Usage ()
* GrokProcessor: Rationalize the loop over the map to save allocations and indirection
* IngestDocument: Rationalize way we append to `List`
2018-07-30 21:25:30 +02:00
Ryan Ernst
49d4b26f16
Ingest: Support integer and long hex values in convert ()
This commit adds checks for hex formatted strings in the convert
processor, allowing strings like `0x1` to be parsed as integer `1`.

closes 
2018-07-24 12:05:50 -07:00
Armin Braun
7aa8a0a927
INGEST: Extend KV Processor () ()
* INGEST: Extend KV Processor ()

Added more capabilities supported by LS to the KV processor:
* Stripping of brackets and quotes from values (`include_brackets` in corresponding LS filter)
* Adding key prefixes
* Trimming specified chars from keys and values

Refactored the way the filter is configured to avoid conditionals during execution.
Refactored Tests a little to not have to add more redundant getters for new parameters.

Relates 
* Add documentation
2018-07-20 22:32:50 +02:00
Armin Braun
e21692e387
INGEST: Make a few Processors callable by Painless ()
* INGEST: Make a few Processors callable by Painless
* Extracted a few stateless String processors as well as the json processor to static methods and whitelisted them in Painless
* provide whitelist from processors plugin
2018-07-20 21:10:35 +02:00
Armin Braun
b65c586cef
Cleanup Duplication in PainlessScriptEngine ()
* Cleanup Duplication in `PainlessScriptEngine`
* Extract duplicate building of compiler settings to method
* Remove dead method params + dead constant in `ScriptProcessor`
2018-07-14 13:37:59 +02:00
Armin Braun
3679d00a74
Replace Ingest ScriptContext with Custom Interface ()
* Replace Ingest ScriptContext with Custom Interface
* Make org.elasticsearch.ingest.common.ScriptProcessorTests#testScripting more precise
* Don't mock script factory in ScriptProcessorTests
* Adjust mock script plugin in IT for new API
2018-07-13 23:26:10 +02:00
Jake Landis
51bb27a991
ingest: date_index_name processor template resolution ()
This change adds support for template snippet (e.g. {{foo}}) resolution
in the date_index_name processor. The following configuration options
will now resolve a templated value if so configured:

* index_name_prefix  (e.g "index_name_prefix": "myindex-{{foo}}-")
* date_rounding (e.g. "date_rounding" : "{{bar}}")
* index_name_format (e.g."index_name_format": "{{baz}}")
2018-07-11 10:13:41 -05:00
Armin Braun
5f5157a2dc
Ingest: Enable Templated Fieldnames in Rename ()
* Ingest: Enable Templated Fieldnames in Rename
2018-07-09 13:50:21 +02:00
Armin Braun
e46ed73379
Ingest: Add ignore_missing option to RemoveProc ()
Added `ignore_missing` setting to the RemoveProcessor to fix 
2018-07-09 10:24:34 +02:00
Christoph Büscher
bd1c513422
Reduce more raw types warnings ()
Similar to .
2018-07-05 15:38:06 +02:00
Jake Landis
c0056cddd8
ingest: Introduction of a bytes processor ()
ingest: Introduction of a bytes processor

This processor allows for human readable byte values (e.g. 1kb) to be converted to value in bytes (e.g. 1024). Internally this processor re-uses "ByteSizeValue.parseBytesSizeValue" which supports conversions up to Long.MAX_VALUE and the following units: "b", "kb", "mb", "gb", "tb", pb".

This change also introduces a generic return type for the AbstractStringProcessor to allow for code reuse while supporting a String -> T conversion. (String -> Long in this case).
2018-07-03 10:40:56 -05:00
Armin Braun
13e1cf6191
ingest: Add ignore_missing property to foreach filter () () 2018-06-26 20:04:41 +02:00
Ryan Ernst
7a150ec06d
Core: Combine doExecute methods in TransportAction ()
TransportAction currently contains 2 doExecute methods, one which takes
a the task, and one that does not. The latter is what some subclasses
implement, while the first one just calls the latter, dropping the given
task. This commit combines these methods, in favor of just always
assuming a task is present.
2018-06-22 15:03:01 -07:00
Ryan Ernst
4f9332ee16
Core: Remove ThreadPool from base TransportAction ()
Most transport actions don't need the node ThreadPool. This commit
removes the ThreadPool as a super constructor parameter for
TransportAction. The actions that do need the thread pool then have a
member added to keep it from their own constructor.
2018-06-21 11:25:26 -07:00
Ryan Ernst
401800d958
Core: Remove index name resolver from base TransportAction ()
Most transport actions don't need to resolve index names. This commit
removes the index name resolver as a super constructor parameter for
TransportAction. The actions that do need the resolver then have a
member added to keep the resolver from their own constructor.
2018-06-19 17:06:09 -07:00
Ryan Ernst
e67aa96c81
Core: Combine Action and GenericAction ()
Since , Action no longer has anything but a call to the
GenericAction super constructor. This commit renames GenericAction
into Action, thus eliminating the Action class. Additionally, this
commit removes the Request generic parameter of the class, since
it was unused.
2018-06-18 23:53:04 +02:00
Martijn van Groningen
6030d4be1e
[INGEST] Interrupt the current thread if evaluation grok expressions take too long ()
This adds a thread interrupter that allows us to encapsulate calls to org.joni.Matcher#search()
This method can hang forever if the regex expression is too complex.

The thread interrupter in the background checks every 3 seconds whether there are threads
execution the org.joni.Matcher#search() method for longer than 5 seconds and
if so interrupts these threads.

Joni has checks that that for every 30k iterations it checks if the current thread is interrupted and
if so returns org.joni.Matcher#INTERRUPTED

Closes 
2018-06-12 07:49:03 +02:00
Tanguy Leroux
bf58660482
Remove all unused imports and fix CRLF ()
The X-Pack opening and the recent other refactorings left a lot of 
unused imports in the codebase. This commit removes them all.
2018-06-11 15:12:12 +02:00
Ryan Ernst
46e8d97813
Core: Remove RequestBuilder from Action ()
This commit removes the RequestBuilder generic type from Action. It was
needed to be used by the newRequest method, which in turn was used by
client.prepareExecute. Both of these methods are now removed, along with
the existing users of prepareExecute constructing the appropriate
builder directly.
2018-05-31 16:15:00 +02:00
Lee Hinman
8e8fdc4f0e
Decouple XContentBuilder from BytesReference ()
* Decouple XContentBuilder from BytesReference

This commit removes all mentions of `BytesReference` from `XContentBuilder`.
This is needed so that we can completely decouple the XContent code and move it
into its own dependency.

While this change appears large, it is due to two main changes, moving
`.bytes()` and `.string()` out of XContentBuilder itself into static methods
`BytesReference.bytes` and `Strings.toString` respectively. The rest of the
change is code reacting to these changes (the majority of it in tests).

Relates to 
2018-03-14 13:47:57 -06:00
Lee Hinman
e7d1e12675
Wrap stream passed to createParser in try-with-resources ()
* Wrap stream passed to createParser in try-with-resources

This wraps the stream (`.streamInput()`) that is passed to many of the
`createParser` instances in the enclosing (or a new) try-with-resources block.
This ensures the `BytesReference.streamInput()` is closed.

Relates to 

* Use try-with-resources instead of closing in a finally block
2018-03-04 16:48:03 -07:00
Luca Cavanna
1df711c5b7
Remove AcknowledgedRestListener in favour of RestToXContentListener ()
This commit makes AcknowledgedResponse implement ToXContentObject, so that the response knows how to print its own content out to XContent, which allows us to remove AcknowledgedRestListener.
2018-02-22 09:13:30 +01:00
Lee Hinman
d7eae4b90f
Pass InputStream when creating XContent parser ()
* Pass InputStream when creating XContent parser

Rather than passing the raw `BytesReference` in when creating the xcontent
parser, this passes the StreamInput (which is an InputStream), this allows us to
decouple XContent from BytesReference.

This also removes the use of `commons.Booleans` so it doesn't require more
external commons classes.

Related to 

* Undo boolean removal

* Enhance deprecation javadoc
2018-02-21 11:03:25 -07:00
Martijn van Groningen
9c405e8595 made load method private and add another static getter that users of Grok can use to get the builtin patterns. 2018-02-20 08:09:24 +01:00
Martijn van Groningen
9e13cb59a2 Moved Grok helper code to a separate Gradle module and
let ingest-common module depend on it.
2018-02-19 09:49:07 +01:00
Lee Hinman
b59b1cf59d
Move more XContent.createParser calls to non-deprecated version ()
* Move more XContent.createParser calls to non-deprecated version

Part 2

This moves more of the callers to pass in the DeprecationHandler.

Relates to 

* Use parser's deprecation handler where appropriate

* Use logging handler in test that uses deprecated field on purpose
2018-02-14 11:24:48 -07:00
Lee Hinman
eebff4d2b3
Use non deprecated xcontenthelper ()
* Move to non-deprecated XContentHelper.createParser(...)

This moves away from one of the now-deprecated XContentHelper.createParser
methods in favor of specifying the deprecation logger at parser creation time.

Relates to 

Note that this doesn't move all the `createParser` calls because some of them
use the already-deprecated method that doesn't specify the XContentType.

* Remove the deprecated (and now non-needed) createParser method
2018-02-05 16:18:18 -07:00
Nik Everett
3b6af15a60
XContent: Factor deprecation handling into callback ()
Factors the way in which XContent parsing handles deprecated fields
into a callback that is set at parser construction time. The goals here
are:
1. Remove Log4J as a dependency of XContent so that XContent can be used
by clients without forcing log4j and our particular deprecation handling
scheme.
2. Simplify handling of deprecated fields in tests. Now tests can listen
directly for the deprecation callback rather than digging through a
ThreadLocal.

More accurately, this change begins this work. It deprecates a number of
methods, pointing folks to the new versions of those methods that take
`DeprecationHandler`. The plan is to slowly drop these deprecated
methods. Once they are entirely removed we can remove Log4j as
dependency of XContent.
2018-01-30 18:21:10 -05:00
Sian Lerk Lau
5e3ba8a88d Enable convert processor to support Long and Double. ()
Closes 
2018-01-03 11:27:55 +01:00
Sian Lerk Lau
47eefbe889 Enable grok processor to support long, double and boolean () 2017-12-20 11:19:49 -08:00
Tal Levy
5c34533761
add json-processor support for non-map json types ()
The Json Processor originally only supported parsing field values into Maps even
though the JSON spec specifies that strings, null-values, numbers, booleans, and arrays
are also valid JSON types. This commit enables parsing these values now.

response to .
2017-11-13 10:28:19 -08:00
Tal Levy
d22fd4ea58
Introduce templating support to timezone/locale in DateProcessor ()
Sometimes systems like Beats would want to extract the date's timezone and/or locale
from a value in a field of the document. This PR adds support for mustache templating
to extract these values.

Closes .
2017-11-09 09:45:32 -08:00
Martijn van Groningen
93107f8466
removed unused import 2017-10-23 10:00:54 +02:00
Martijn van Groningen
141d1b62e9
ingest: date processor should not fail if timestamp is specified as json number
Closes 
2017-10-23 09:32:44 +02:00
kel
2e36f19051 Add support for parsing inline script () ()
* Add support for parsing inline script ()

* Fix test
2017-10-11 09:15:37 -07:00
Martijn van Groningen
bba70205e3
ingest: Fix bug that prevent date_index_name processor from accepting timestamps specified as a json number
Closes 
2017-10-10 10:04:29 +02:00
Jiri Tyr
76f8701eec Fixing Grok pattern for Apache 2.4 () 2017-09-25 07:59:37 -07:00
Adrien Grand
34a6c7af26 Consolidate locale parsing. ()
Mappings and ingest have different locale parsing code.
2017-08-30 10:58:33 +02:00
Stuart Neivandt
f842ff1ae1 Simple verification of the format of the language tag used in DateProcessor. ()
Closes 
2017-08-28 10:59:00 +02:00
Tal Levy
872526cad3 add URL-Decode Processor to Ingest ()
closes 

Adds a URL Decoder Processor to Ingest

this will decode urls like:

https%3a%2f%2felastic.co%2 to https://elastic.co/
2017-08-07 10:26:11 -07:00
Jack Conradson
d2b4f7ac5a Disallow lang to be used with Stored Scripts ()
Requests that execute a stored script will no longer be allowed to specify the lang of the script. This information is stored in the cluster state making only an id necessary to execute against. Putting a stored script will still require a lang.
2017-07-12 07:55:57 -07:00
Tal Levy
2cd771a230 fix: Sort Processor does not have proper behavior with targetField ()
to specify a `targetField`. This results in some interesting behavior that was missed in the review.
This processor sorts in-place, so there is a side-effect in both the original field and the target field.
Another bug was that the targetField was not being set if the list being sorted was fewer than two elements.

The new behavior works like this: If targetField and fieldName are not the same, we copy the list.
2017-06-15 05:28:54 -07:00
Alexander Kazakov
a7dafdaa05 Add target_field parameter to gsub, join, lowercase, sort, split, trim, uppercase ()
Closes  
2017-06-13 09:40:44 -07:00