ingest-node.asciidoc 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169
  1. [[pipeline]]
  2. == Pipeline Definition
  3. A pipeline is a definition of a series of <<ingest-processors, processors>> that are to be executed
  4. in the same order as they are declared. A pipeline consists of two main fields: a `description`
  5. and a list of `processors`:
  6. [source,js]
  7. --------------------------------------------------
  8. {
  9. "description" : "...",
  10. "processors" : [ ... ]
  11. }
  12. --------------------------------------------------
  13. // NOTCONSOLE
  14. The `description` is a special field to store a helpful description of
  15. what the pipeline does.
  16. The `processors` parameter defines a list of processors to be executed in
  17. order.
  18. [[ingest-apis]]
  19. == Ingest APIs
  20. The following ingest APIs are available for managing pipelines:
  21. * <<put-pipeline-api>> to add or update a pipeline
  22. * <<get-pipeline-api>> to return a specific pipeline
  23. * <<delete-pipeline-api>> to delete a pipeline
  24. * <<simulate-pipeline-api>> to simulate a call to a pipeline
  25. [[put-pipeline-api]]
  26. === Put Pipeline API
  27. The put pipeline API adds pipelines and updates existing pipelines in the cluster.
  28. [source,js]
  29. --------------------------------------------------
  30. PUT _ingest/pipeline/my-pipeline-id
  31. {
  32. "description" : "describe pipeline",
  33. "processors" : [
  34. {
  35. "set" : {
  36. "field": "foo",
  37. "value": "bar"
  38. }
  39. }
  40. ]
  41. }
  42. --------------------------------------------------
  43. // CONSOLE
  44. NOTE: The put pipeline API also instructs all ingest nodes to reload their in-memory representation of pipelines, so that
  45. pipeline changes take effect immediately.
  46. [[get-pipeline-api]]
  47. === Get Pipeline API
  48. The get pipeline API returns pipelines based on ID. This API always returns a local reference of the pipeline.
  49. [source,js]
  50. --------------------------------------------------
  51. GET _ingest/pipeline/my-pipeline-id
  52. --------------------------------------------------
  53. // CONSOLE
  54. // TEST[continued]
  55. Example response:
  56. [source,js]
  57. --------------------------------------------------
  58. {
  59. "my-pipeline-id" : {
  60. "description" : "describe pipeline",
  61. "processors" : [
  62. {
  63. "set" : {
  64. "field" : "foo",
  65. "value" : "bar"
  66. }
  67. }
  68. ]
  69. }
  70. }
  71. --------------------------------------------------
  72. // TESTRESPONSE
  73. For each returned pipeline, the source and the version are returned.
  74. The version is useful for knowing which version of the pipeline the node has.
  75. You can specify multiple IDs to return more than one pipeline. Wildcards are also supported.
  76. [float]
  77. [[versioning-pipelines]]
  78. ==== Pipeline Versioning
  79. Pipelines can optionally add a `version` number, which can be any integer value,
  80. in order to simplify pipeline management by external systems. The `version`
  81. field is completely optional and it is meant solely for external management of
  82. pipelines. To unset a `version`, simply replace the pipeline without specifying
  83. one.
  84. [source,js]
  85. --------------------------------------------------
  86. PUT _ingest/pipeline/my-pipeline-id
  87. {
  88. "description" : "describe pipeline",
  89. "version" : 123,
  90. "processors" : [
  91. {
  92. "set" : {
  93. "field": "foo",
  94. "value": "bar"
  95. }
  96. }
  97. ]
  98. }
  99. --------------------------------------------------
  100. // CONSOLE
  101. To check for the `version`, you can
  102. <<common-options-response-filtering, filter responses>>
  103. using `filter_path` to limit the response to just the `version`:
  104. [source,js]
  105. --------------------------------------------------
  106. GET /_ingest/pipeline/my-pipeline-id?filter_path=*.version
  107. --------------------------------------------------
  108. // CONSOLE
  109. // TEST[continued]
  110. This should give a small response that makes it both easy and inexpensive to parse:
  111. [source,js]
  112. --------------------------------------------------
  113. {
  114. "my-pipeline-id" : {
  115. "version" : 123
  116. }
  117. }
  118. --------------------------------------------------
  119. // TESTRESPONSE
  120. [[delete-pipeline-api]]
  121. === Delete Pipeline API
  122. The delete pipeline API deletes pipelines by ID or wildcard match (`my-*`, `*`).
  123. [source,js]
  124. --------------------------------------------------
  125. DELETE _ingest/pipeline/my-pipeline-id
  126. --------------------------------------------------
  127. // CONSOLE
  128. // TEST[continued]
  129. ////
  130. Hidden setup for wildcard test:
  131. [source,js]
  132. --------------------------------------------------
  133. PUT _ingest/pipeline/wild-one
  134. {
  135. "description" : "first pipeline to be wildcard deleted",
  136. "processors" : [ ]
  137. }
  138. PUT _ingest/pipeline/wild-two
  139. {
  140. "description" : "second pipeline to be wildcard deleted",
  141. "processors" : [ ]
  142. }
  143. DELETE _ingest/pipeline/*
  144. --------------------------------------------------
  145. // CONSOLE
  146. Hidden expected response:
  147. [source,js]
  148. --------------------------------------------------
  149. {
  150. "acknowledged": true
  151. }
  152. --------------------------------------------------
  153. // TESTRESPONSE
  154. ////
  155. [[simulate-pipeline-api]]
  156. === Simulate Pipeline API
  157. The simulate pipeline API executes a specific pipeline against
  158. the set of documents provided in the body of the request.
  159. You can either specify an existing pipeline to execute
  160. against the provided documents, or supply a pipeline definition in
  161. the body of the request.
  162. Here is the structure of a simulate request with a pipeline definition provided
  163. in the body of the request:
  164. [source,js]
  165. --------------------------------------------------
  166. POST _ingest/pipeline/_simulate
  167. {
  168. "pipeline" : {
  169. // pipeline definition here
  170. },
  171. "docs" : [
  172. { "_source": {/** first document **/} },
  173. { "_source": {/** second document **/} },
  174. // ...
  175. ]
  176. }
  177. --------------------------------------------------
  178. // NOTCONSOLE
  179. Here is the structure of a simulate request against an existing pipeline:
  180. [source,js]
  181. --------------------------------------------------
  182. POST _ingest/pipeline/my-pipeline-id/_simulate
  183. {
  184. "docs" : [
  185. { "_source": {/** first document **/} },
  186. { "_source": {/** second document **/} },
  187. // ...
  188. ]
  189. }
  190. --------------------------------------------------
  191. // NOTCONSOLE
  192. Here is an example of a simulate request with a pipeline defined in the request
  193. and its response:
  194. [source,js]
  195. --------------------------------------------------
  196. POST _ingest/pipeline/_simulate
  197. {
  198. "pipeline" :
  199. {
  200. "description": "_description",
  201. "processors": [
  202. {
  203. "set" : {
  204. "field" : "field2",
  205. "value" : "_value"
  206. }
  207. }
  208. ]
  209. },
  210. "docs": [
  211. {
  212. "_index": "index",
  213. "_type": "_doc",
  214. "_id": "id",
  215. "_source": {
  216. "foo": "bar"
  217. }
  218. },
  219. {
  220. "_index": "index",
  221. "_type": "_doc",
  222. "_id": "id",
  223. "_source": {
  224. "foo": "rab"
  225. }
  226. }
  227. ]
  228. }
  229. --------------------------------------------------
  230. // CONSOLE
  231. Response:
  232. [source,js]
  233. --------------------------------------------------
  234. {
  235. "docs": [
  236. {
  237. "doc": {
  238. "_id": "id",
  239. "_index": "index",
  240. "_type": "_doc",
  241. "_source": {
  242. "field2": "_value",
  243. "foo": "bar"
  244. },
  245. "_ingest": {
  246. "timestamp": "2017-05-04T22:30:03.187Z"
  247. }
  248. }
  249. },
  250. {
  251. "doc": {
  252. "_id": "id",
  253. "_index": "index",
  254. "_type": "_doc",
  255. "_source": {
  256. "field2": "_value",
  257. "foo": "rab"
  258. },
  259. "_ingest": {
  260. "timestamp": "2017-05-04T22:30:03.188Z"
  261. }
  262. }
  263. }
  264. ]
  265. }
  266. --------------------------------------------------
  267. // TESTRESPONSE[s/"2017-05-04T22:30:03.187Z"/$body.docs.0.doc._ingest.timestamp/]
  268. // TESTRESPONSE[s/"2017-05-04T22:30:03.188Z"/$body.docs.1.doc._ingest.timestamp/]
  269. [[ingest-verbose-param]]
  270. ==== Viewing Verbose Results
  271. You can use the simulate pipeline API to see how each processor affects the ingest document
  272. as it passes through the pipeline. To see the intermediate results of
  273. each processor in the simulate request, you can add the `verbose` parameter
  274. to the request.
  275. Here is an example of a verbose request and its response:
  276. [source,js]
  277. --------------------------------------------------
  278. POST _ingest/pipeline/_simulate?verbose
  279. {
  280. "pipeline" :
  281. {
  282. "description": "_description",
  283. "processors": [
  284. {
  285. "set" : {
  286. "field" : "field2",
  287. "value" : "_value2"
  288. }
  289. },
  290. {
  291. "set" : {
  292. "field" : "field3",
  293. "value" : "_value3"
  294. }
  295. }
  296. ]
  297. },
  298. "docs": [
  299. {
  300. "_index": "index",
  301. "_type": "_doc",
  302. "_id": "id",
  303. "_source": {
  304. "foo": "bar"
  305. }
  306. },
  307. {
  308. "_index": "index",
  309. "_type": "_doc",
  310. "_id": "id",
  311. "_source": {
  312. "foo": "rab"
  313. }
  314. }
  315. ]
  316. }
  317. --------------------------------------------------
  318. // CONSOLE
  319. Response:
  320. [source,js]
  321. --------------------------------------------------
  322. {
  323. "docs": [
  324. {
  325. "processor_results": [
  326. {
  327. "doc": {
  328. "_id": "id",
  329. "_index": "index",
  330. "_type": "_doc",
  331. "_source": {
  332. "field2": "_value2",
  333. "foo": "bar"
  334. },
  335. "_ingest": {
  336. "timestamp": "2017-05-04T22:46:09.674Z"
  337. }
  338. }
  339. },
  340. {
  341. "doc": {
  342. "_id": "id",
  343. "_index": "index",
  344. "_type": "_doc",
  345. "_source": {
  346. "field3": "_value3",
  347. "field2": "_value2",
  348. "foo": "bar"
  349. },
  350. "_ingest": {
  351. "timestamp": "2017-05-04T22:46:09.675Z"
  352. }
  353. }
  354. }
  355. ]
  356. },
  357. {
  358. "processor_results": [
  359. {
  360. "doc": {
  361. "_id": "id",
  362. "_index": "index",
  363. "_type": "_doc",
  364. "_source": {
  365. "field2": "_value2",
  366. "foo": "rab"
  367. },
  368. "_ingest": {
  369. "timestamp": "2017-05-04T22:46:09.676Z"
  370. }
  371. }
  372. },
  373. {
  374. "doc": {
  375. "_id": "id",
  376. "_index": "index",
  377. "_type": "_doc",
  378. "_source": {
  379. "field3": "_value3",
  380. "field2": "_value2",
  381. "foo": "rab"
  382. },
  383. "_ingest": {
  384. "timestamp": "2017-05-04T22:46:09.677Z"
  385. }
  386. }
  387. }
  388. ]
  389. }
  390. ]
  391. }
  392. --------------------------------------------------
  393. // TESTRESPONSE[s/"2017-05-04T22:46:09.674Z"/$body.docs.0.processor_results.0.doc._ingest.timestamp/]
  394. // TESTRESPONSE[s/"2017-05-04T22:46:09.675Z"/$body.docs.0.processor_results.1.doc._ingest.timestamp/]
  395. // TESTRESPONSE[s/"2017-05-04T22:46:09.676Z"/$body.docs.1.processor_results.0.doc._ingest.timestamp/]
  396. // TESTRESPONSE[s/"2017-05-04T22:46:09.677Z"/$body.docs.1.processor_results.1.doc._ingest.timestamp/]
  397. [[accessing-data-in-pipelines]]
  398. == Accessing Data in Pipelines
  399. The processors in a pipeline have read and write access to documents that pass through the pipeline.
  400. The processors can access fields in the source of a document and the document's metadata fields.
  401. [float]
  402. [[accessing-source-fields]]
  403. === Accessing Fields in the Source
  404. Accessing a field in the source is straightforward. You simply refer to fields by
  405. their name. For example:
  406. [source,js]
  407. --------------------------------------------------
  408. {
  409. "set": {
  410. "field": "my_field",
  411. "value": 582.1
  412. }
  413. }
  414. --------------------------------------------------
  415. // NOTCONSOLE
  416. On top of this, fields from the source are always accessible via the `_source` prefix:
  417. [source,js]
  418. --------------------------------------------------
  419. {
  420. "set": {
  421. "field": "_source.my_field",
  422. "value": 582.1
  423. }
  424. }
  425. --------------------------------------------------
  426. // NOTCONSOLE
  427. [float]
  428. [[accessing-metadata-fields]]
  429. === Accessing Metadata Fields
  430. You can access metadata fields in the same way that you access fields in the source. This
  431. is possible because Elasticsearch doesn't allow fields in the source that have the
  432. same name as metadata fields.
  433. The following example sets the `_id` metadata field of a document to `1`:
  434. [source,js]
  435. --------------------------------------------------
  436. {
  437. "set": {
  438. "field": "_id",
  439. "value": "1"
  440. }
  441. }
  442. --------------------------------------------------
  443. // NOTCONSOLE
  444. The following metadata fields are accessible by a processor: `_index`, `_type`, `_id`, `_routing`.
  445. [float]
  446. [[accessing-ingest-metadata]]
  447. === Accessing Ingest Metadata Fields
  448. Beyond metadata fields and source fields, ingest also adds ingest metadata to the documents that it processes.
  449. These metadata properties are accessible under the `_ingest` key. Currently ingest adds the ingest timestamp
  450. under the `_ingest.timestamp` key of the ingest metadata. The ingest timestamp is the time when Elasticsearch
  451. received the index or bulk request to pre-process the document.
  452. Any processor can add ingest-related metadata during document processing. Ingest metadata is transient
  453. and is lost after a document has been processed by the pipeline. Therefore, ingest metadata won't be indexed.
  454. The following example adds a field with the name `received`. The value is the ingest timestamp:
  455. [source,js]
  456. --------------------------------------------------
  457. {
  458. "set": {
  459. "field": "received",
  460. "value": "{{_ingest.timestamp}}"
  461. }
  462. }
  463. --------------------------------------------------
  464. // NOTCONSOLE
  465. Unlike Elasticsearch metadata fields, the ingest metadata field name `_ingest` can be used as a valid field name
  466. in the source of a document. Use `_source._ingest` to refer to the field in the source document. Otherwise, `_ingest`
  467. will be interpreted as an ingest metadata field.
  468. [float]
  469. [[accessing-template-fields]]
  470. === Accessing Fields and Metafields in Templates
  471. A number of processor settings also support templating. Settings that support templating can have zero or more
  472. template snippets. A template snippet begins with `{{` and ends with `}}`.
  473. Accessing fields and metafields in templates is exactly the same as via regular processor field settings.
  474. The following example adds a field named `field_c`. Its value is a concatenation of
  475. the values of `field_a` and `field_b`.
  476. [source,js]
  477. --------------------------------------------------
  478. {
  479. "set": {
  480. "field": "field_c",
  481. "value": "{{field_a}} {{field_b}}"
  482. }
  483. }
  484. --------------------------------------------------
  485. // NOTCONSOLE
  486. The following example uses the value of the `geoip.country_iso_code` field in the source
  487. to set the index that the document will be indexed into:
  488. [source,js]
  489. --------------------------------------------------
  490. {
  491. "set": {
  492. "field": "_index",
  493. "value": "{{geoip.country_iso_code}}"
  494. }
  495. }
  496. --------------------------------------------------
  497. // NOTCONSOLE
  498. Dynamic field names are also supported. This example sets the field named after the
  499. value of `service` to the value of the field `code`:
  500. [source,js]
  501. --------------------------------------------------
  502. {
  503. "set": {
  504. "field": "{{service}}",
  505. "value": "{{code}}"
  506. }
  507. }
  508. --------------------------------------------------
  509. // NOTCONSOLE
  510. [[handling-failure-in-pipelines]]
  511. == Handling Failures in Pipelines
  512. In its simplest use case, a pipeline defines a list of processors that
  513. are executed sequentially, and processing halts at the first exception. This
  514. behavior may not be desirable when failures are expected. For example, you may have logs
  515. that don't match the specified grok expression. Instead of halting execution, you may
  516. want to index such documents into a separate index.
  517. To enable this behavior, you can use the `on_failure` parameter. The `on_failure` parameter
  518. defines a list of processors to be executed immediately following the failed processor.
  519. You can specify this parameter at the pipeline level, as well as at the processor
  520. level. If a processor specifies an `on_failure` configuration, whether
  521. it is empty or not, any exceptions that are thrown by the processor are caught, and the
  522. pipeline continues executing the remaining processors. Because you can define further processors
  523. within the scope of an `on_failure` statement, you can nest failure handling.
  524. The following example defines a pipeline that renames the `foo` field in
  525. the processed document to `bar`. If the document does not contain the `foo` field, the processor
  526. attaches an error message to the document for later analysis within
  527. Elasticsearch.
  528. [source,js]
  529. --------------------------------------------------
  530. {
  531. "description" : "my first pipeline with handled exceptions",
  532. "processors" : [
  533. {
  534. "rename" : {
  535. "field" : "foo",
  536. "target_field" : "bar",
  537. "on_failure" : [
  538. {
  539. "set" : {
  540. "field" : "error",
  541. "value" : "field \"foo\" does not exist, cannot rename to \"bar\""
  542. }
  543. }
  544. ]
  545. }
  546. }
  547. ]
  548. }
  549. --------------------------------------------------
  550. // NOTCONSOLE
  551. The following example defines an `on_failure` block on a whole pipeline to change
  552. the index to which failed documents get sent.
  553. [source,js]
  554. --------------------------------------------------
  555. {
  556. "description" : "my first pipeline with handled exceptions",
  557. "processors" : [ ... ],
  558. "on_failure" : [
  559. {
  560. "set" : {
  561. "field" : "_index",
  562. "value" : "failed-{{ _index }}"
  563. }
  564. }
  565. ]
  566. }
  567. --------------------------------------------------
  568. // NOTCONSOLE
  569. Alternatively instead of defining behaviour in case of processor failure, it is also possible
  570. to ignore a failure and continue with the next processor by specifying the `ignore_failure` setting.
  571. In case in the example below the field `foo` doesn't exist the failure will be caught and the pipeline
  572. continues to execute, which in this case means that the pipeline does nothing.
  573. [source,js]
  574. --------------------------------------------------
  575. {
  576. "description" : "my first pipeline with handled exceptions",
  577. "processors" : [
  578. {
  579. "rename" : {
  580. "field" : "foo",
  581. "target_field" : "bar",
  582. "ignore_failure" : true
  583. }
  584. }
  585. ]
  586. }
  587. --------------------------------------------------
  588. // NOTCONSOLE
  589. The `ignore_failure` can be set on any processor and defaults to `false`.
  590. [float]
  591. [[accessing-error-metadata]]
  592. === Accessing Error Metadata From Processors Handling Exceptions
  593. You may want to retrieve the actual error message that was thrown
  594. by a failed processor. To do so you can access metadata fields called
  595. `on_failure_message`, `on_failure_processor_type`, and `on_failure_processor_tag`. These fields are only accessible
  596. from within the context of an `on_failure` block.
  597. Here is an updated version of the example that you
  598. saw earlier. But instead of setting the error message manually, the example leverages the `on_failure_message`
  599. metadata field to provide the error message.
  600. [source,js]
  601. --------------------------------------------------
  602. {
  603. "description" : "my first pipeline with handled exceptions",
  604. "processors" : [
  605. {
  606. "rename" : {
  607. "field" : "foo",
  608. "to" : "bar",
  609. "on_failure" : [
  610. {
  611. "set" : {
  612. "field" : "error",
  613. "value" : "{{ _ingest.on_failure_message }}"
  614. }
  615. }
  616. ]
  617. }
  618. }
  619. ]
  620. }
  621. --------------------------------------------------
  622. // NOTCONSOLE
  623. [[ingest-processors]]
  624. == Processors
  625. All processors are defined in the following way within a pipeline definition:
  626. [source,js]
  627. --------------------------------------------------
  628. {
  629. "PROCESSOR_NAME" : {
  630. ... processor configuration options ...
  631. }
  632. }
  633. --------------------------------------------------
  634. // NOTCONSOLE
  635. Each processor defines its own configuration parameters, but all processors have
  636. the ability to declare `tag` and `on_failure` fields. These fields are optional.
  637. A `tag` is simply a string identifier of the specific instantiation of a certain
  638. processor in a pipeline. The `tag` field does not affect the processor's behavior,
  639. but is very useful for bookkeeping and tracing errors to specific processors.
  640. See <<handling-failure-in-pipelines>> to learn more about the `on_failure` field and error handling in pipelines.
  641. The <<ingest-info,node info API>> can be used to figure out what processors are available in a cluster.
  642. The <<ingest-info,node info API>> will provide a per node list of what processors are available.
  643. Custom processors must be installed on all nodes. The put pipeline API will fail if a processor specified in a pipeline
  644. doesn't exist on all nodes. If you rely on custom processor plugins make sure to mark these plugins as mandatory by adding
  645. `plugin.mandatory` setting to the `config/elasticsearch.yml` file, for example:
  646. [source,yaml]
  647. --------------------------------------------------
  648. plugin.mandatory: ingest-attachment,ingest-geoip
  649. --------------------------------------------------
  650. A node will not start if either of these plugins are not available.
  651. The <<ingest-stats,node stats API>> can be used to fetch ingest usage statistics, globally and on a per
  652. pipeline basis. Useful to find out which pipelines are used the most or spent the most time on preprocessing.
  653. [[append-processor]]
  654. === Append Processor
  655. Appends one or more values to an existing array if the field already exists and it is an array.
  656. Converts a scalar to an array and appends one or more values to it if the field exists and it is a scalar.
  657. Creates an array containing the provided values if the field doesn't exist.
  658. Accepts a single value or an array of values.
  659. [[append-options]]
  660. .Append Options
  661. [options="header"]
  662. |======
  663. | Name | Required | Default | Description
  664. | `field` | yes | - | The field to be appended to
  665. | `value` | yes | - | The value to be appended
  666. |======
  667. [source,js]
  668. --------------------------------------------------
  669. {
  670. "append": {
  671. "field": "field1",
  672. "value": ["item2", "item3", "item4"]
  673. }
  674. }
  675. --------------------------------------------------
  676. // NOTCONSOLE
  677. [[convert-processor]]
  678. === Convert Processor
  679. Converts an existing field's value to a different type, such as converting a string to an integer.
  680. If the field value is an array, all members will be converted.
  681. The supported types include: `integer`, `long`, `float`, `double`, `string`, `boolean`, and `auto`.
  682. Specifying `boolean` will set the field to true if its string value is equal to `true` (ignore case), to
  683. false if its string value is equal to `false` (ignore case), or it will throw an exception otherwise.
  684. Specifying `auto` will attempt to convert the string-valued `field` into the closest non-string type.
  685. For example, a field whose value is `"true"` will be converted to its respective boolean type: `true`. Do note
  686. that float takes precedence of double in `auto`. A value of `"242.15"` will "automatically" be converted to
  687. `242.15` of type `float`. If a provided field cannot be appropriately converted, the Convert Processor will
  688. still process successfully and leave the field value as-is. In such a case, `target_field` will
  689. still be updated with the unconverted field value.
  690. [[convert-options]]
  691. .Convert Options
  692. [options="header"]
  693. |======
  694. | Name | Required | Default | Description
  695. | `field` | yes | - | The field whose value is to be converted
  696. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  697. | `type` | yes | - | The type to convert the existing value to
  698. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  699. |======
  700. [source,js]
  701. --------------------------------------------------
  702. {
  703. "convert": {
  704. "field" : "foo",
  705. "type": "integer"
  706. }
  707. }
  708. --------------------------------------------------
  709. // NOTCONSOLE
  710. [[date-processor]]
  711. === Date Processor
  712. Parses dates from fields, and then uses the date or timestamp as the timestamp for the document.
  713. By default, the date processor adds the parsed date as a new field called `@timestamp`. You can specify a
  714. different field by setting the `target_field` configuration parameter. Multiple date formats are supported
  715. as part of the same date processor definition. They will be used sequentially to attempt parsing the date field,
  716. in the same order they were defined as part of the processor definition.
  717. [[date-options]]
  718. .Date options
  719. [options="header"]
  720. |======
  721. | Name | Required | Default | Description
  722. | `field` | yes | - | The field to get the date from.
  723. | `target_field` | no | @timestamp | The field that will hold the parsed date.
  724. | `formats` | yes | - | An array of the expected date formats. Can be a Joda pattern or one of the following formats: ISO8601, UNIX, UNIX_MS, or TAI64N.
  725. | `timezone` | no | UTC | The timezone to use when parsing the date.
  726. | `locale` | no | ENGLISH | The locale to use when parsing the date, relevant when parsing month names or week days.
  727. |======
  728. Here is an example that adds the parsed date to the `timestamp` field based on the `initial_date` field:
  729. [source,js]
  730. --------------------------------------------------
  731. {
  732. "description" : "...",
  733. "processors" : [
  734. {
  735. "date" : {
  736. "field" : "initial_date",
  737. "target_field" : "timestamp",
  738. "formats" : ["dd/MM/yyyy hh:mm:ss"],
  739. "timezone" : "Europe/Amsterdam"
  740. }
  741. }
  742. ]
  743. }
  744. --------------------------------------------------
  745. // NOTCONSOLE
  746. The `timezone` and `locale` processor parameters are templated. This means that their values can be
  747. extracted from fields within documents. The example below shows how to extract the locale/timezone
  748. details from existing fields, `my_timezone` and `my_locale`, in the ingested document that contain
  749. the timezone and locale values.
  750. [source,js]
  751. --------------------------------------------------
  752. {
  753. "description" : "...",
  754. "processors" : [
  755. {
  756. "date" : {
  757. "field" : "initial_date",
  758. "target_field" : "timestamp",
  759. "formats" : ["ISO8601"],
  760. "timezone" : "{{ my_timezone }}",
  761. "locale" : "{{ my_locale }}"
  762. }
  763. }
  764. ]
  765. }
  766. --------------------------------------------------
  767. // NOTCONSOLE
  768. [[date-index-name-processor]]
  769. === Date Index Name Processor
  770. The purpose of this processor is to point documents to the right time based index based
  771. on a date or timestamp field in a document by using the <<date-math-index-names, date math index name support>>.
  772. The processor sets the `_index` meta field with a date math index name expression based on the provided index name
  773. prefix, a date or timestamp field in the documents being processed and the provided date rounding.
  774. First, this processor fetches the date or timestamp from a field in the document being processed. Optionally,
  775. date formatting can be configured on how the field's value should be parsed into a date. Then this date,
  776. the provided index name prefix and the provided date rounding get formatted into a date math index name expression.
  777. Also here optionally date formatting can be specified on how the date should be formatted into a date math index name
  778. expression.
  779. An example pipeline that points documents to a monthly index that starts with a `myindex-` prefix based on a
  780. date in the `date1` field:
  781. [source,js]
  782. --------------------------------------------------
  783. PUT _ingest/pipeline/monthlyindex
  784. {
  785. "description": "monthly date-time index naming",
  786. "processors" : [
  787. {
  788. "date_index_name" : {
  789. "field" : "date1",
  790. "index_name_prefix" : "myindex-",
  791. "date_rounding" : "M"
  792. }
  793. }
  794. ]
  795. }
  796. --------------------------------------------------
  797. // CONSOLE
  798. Using that pipeline for an index request:
  799. [source,js]
  800. --------------------------------------------------
  801. PUT /myindex/_doc/1?pipeline=monthlyindex
  802. {
  803. "date1" : "2016-04-25T12:02:01.789Z"
  804. }
  805. --------------------------------------------------
  806. // CONSOLE
  807. // TEST[continued]
  808. [source,js]
  809. --------------------------------------------------
  810. {
  811. "_index" : "myindex-2016-04-01",
  812. "_type" : "_doc",
  813. "_id" : "1",
  814. "_version" : 1,
  815. "result" : "created",
  816. "_shards" : {
  817. "total" : 2,
  818. "successful" : 1,
  819. "failed" : 0
  820. },
  821. "_seq_no" : 0,
  822. "_primary_term" : 1
  823. }
  824. --------------------------------------------------
  825. // TESTRESPONSE
  826. The above request will not index this document into the `myindex` index, but into the `myindex-2016-04-01` index because
  827. it was rounded by month. This is because the date-index-name-processor overrides the `_index` property of the document.
  828. To see the date-math value of the index supplied in the actual index request which resulted in the above document being
  829. indexed into `myindex-2016-04-01` we can inspect the effects of the processor using a simulate request.
  830. [source,js]
  831. --------------------------------------------------
  832. POST _ingest/pipeline/_simulate
  833. {
  834. "pipeline" :
  835. {
  836. "description": "monthly date-time index naming",
  837. "processors" : [
  838. {
  839. "date_index_name" : {
  840. "field" : "date1",
  841. "index_name_prefix" : "myindex-",
  842. "date_rounding" : "M"
  843. }
  844. }
  845. ]
  846. },
  847. "docs": [
  848. {
  849. "_source": {
  850. "date1": "2016-04-25T12:02:01.789Z"
  851. }
  852. }
  853. ]
  854. }
  855. --------------------------------------------------
  856. // CONSOLE
  857. and the result:
  858. [source,js]
  859. --------------------------------------------------
  860. {
  861. "docs" : [
  862. {
  863. "doc" : {
  864. "_id" : "_id",
  865. "_index" : "<myindex-{2016-04-25||/M{yyyy-MM-dd|UTC}}>",
  866. "_type" : "_type",
  867. "_source" : {
  868. "date1" : "2016-04-25T12:02:01.789Z"
  869. },
  870. "_ingest" : {
  871. "timestamp" : "2016-11-08T19:43:03.850+0000"
  872. }
  873. }
  874. }
  875. ]
  876. }
  877. --------------------------------------------------
  878. // TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/]
  879. The above example shows that `_index` was set to `<myindex-{2016-04-25||/M{yyyy-MM-dd|UTC}}>`. Elasticsearch
  880. understands this to mean `2016-04-01` as is explained in the <<date-math-index-names, date math index name documentation>>
  881. [[date-index-name-options]]
  882. .Date index name options
  883. [options="header"]
  884. |======
  885. | Name | Required | Default | Description
  886. | `field` | yes | - | The field to get the date or timestamp from.
  887. | `index_name_prefix` | no | - | A prefix of the index name to be prepended before the printed date.
  888. | `date_rounding` | yes | - | How to round the date when formatting the date into the index name. Valid values are: `y` (year), `M` (month), `w` (week), `d` (day), `h` (hour), `m` (minute) and `s` (second).
  889. | `date_formats` | no | yyyy-MM-dd'T'HH:mm:ss.SSSZ | An array of the expected date formats for parsing dates / timestamps in the document being preprocessed. Can be a Joda pattern or one of the following formats: ISO8601, UNIX, UNIX_MS, or TAI64N.
  890. | `timezone` | no | UTC | The timezone to use when parsing the date and when date math index supports resolves expressions into concrete index names.
  891. | `locale` | no | ENGLISH | The locale to use when parsing the date from the document being preprocessed, relevant when parsing month names or week days.
  892. | `index_name_format` | no | yyyy-MM-dd | The format to be used when printing the parsed date into the index name. An valid Joda pattern is expected here.
  893. |======
  894. [[fail-processor]]
  895. === Fail Processor
  896. Raises an exception. This is useful for when
  897. you expect a pipeline to fail and want to relay a specific message
  898. to the requester.
  899. [[fail-options]]
  900. .Fail Options
  901. [options="header"]
  902. |======
  903. | Name | Required | Default | Description
  904. | `message` | yes | - | The error message of the `FailException` thrown by the processor
  905. |======
  906. [source,js]
  907. --------------------------------------------------
  908. {
  909. "fail": {
  910. "message": "an error message"
  911. }
  912. }
  913. --------------------------------------------------
  914. // NOTCONSOLE
  915. [[foreach-processor]]
  916. === Foreach Processor
  917. Processes elements in an array of unknown length.
  918. All processors can operate on elements inside an array, but if all elements of an array need to
  919. be processed in the same way, defining a processor for each element becomes cumbersome and tricky
  920. because it is likely that the number of elements in an array is unknown. For this reason the `foreach`
  921. processor exists. By specifying the field holding array elements and a processor that
  922. defines what should happen to each element, array fields can easily be preprocessed.
  923. A processor inside the foreach processor works in the array element context and puts that in the ingest metadata
  924. under the `_ingest._value` key. If the array element is a json object it holds all immediate fields of that json object.
  925. and if the nested object is a value is `_ingest._value` just holds that value. Note that if a processor prior to the
  926. `foreach` processor used `_ingest._value` key then the specified value will not be available to the processor inside
  927. the `foreach` processor. The `foreach` processor does restore the original value, so that value is available to processors
  928. after the `foreach` processor.
  929. Note that any other field from the document are accessible and modifiable like with all other processors. This processor
  930. just puts the current array element being read into `_ingest._value` ingest metadata attribute, so that it may be
  931. pre-processed.
  932. If the `foreach` processor fails to process an element inside the array, and no `on_failure` processor has been specified,
  933. then it aborts the execution and leaves the array unmodified.
  934. [[foreach-options]]
  935. .Foreach Options
  936. [options="header"]
  937. |======
  938. | Name | Required | Default | Description
  939. | `field` | yes | - | The array field
  940. | `processor` | yes | - | The processor to execute against each field
  941. |======
  942. Assume the following document:
  943. [source,js]
  944. --------------------------------------------------
  945. {
  946. "values" : ["foo", "bar", "baz"]
  947. }
  948. --------------------------------------------------
  949. // NOTCONSOLE
  950. When this `foreach` processor operates on this sample document:
  951. [source,js]
  952. --------------------------------------------------
  953. {
  954. "foreach" : {
  955. "field" : "values",
  956. "processor" : {
  957. "uppercase" : {
  958. "field" : "_ingest._value"
  959. }
  960. }
  961. }
  962. }
  963. --------------------------------------------------
  964. // NOTCONSOLE
  965. Then the document will look like this after preprocessing:
  966. [source,js]
  967. --------------------------------------------------
  968. {
  969. "values" : ["FOO", "BAR", "BAZ"]
  970. }
  971. --------------------------------------------------
  972. // NOTCONSOLE
  973. Let's take a look at another example:
  974. [source,js]
  975. --------------------------------------------------
  976. {
  977. "persons" : [
  978. {
  979. "id" : "1",
  980. "name" : "John Doe"
  981. },
  982. {
  983. "id" : "2",
  984. "name" : "Jane Doe"
  985. }
  986. ]
  987. }
  988. --------------------------------------------------
  989. // NOTCONSOLE
  990. In this case, the `id` field needs to be removed,
  991. so the following `foreach` processor is used:
  992. [source,js]
  993. --------------------------------------------------
  994. {
  995. "foreach" : {
  996. "field" : "persons",
  997. "processor" : {
  998. "remove" : {
  999. "field" : "_ingest._value.id"
  1000. }
  1001. }
  1002. }
  1003. }
  1004. --------------------------------------------------
  1005. // NOTCONSOLE
  1006. After preprocessing the result is:
  1007. [source,js]
  1008. --------------------------------------------------
  1009. {
  1010. "persons" : [
  1011. {
  1012. "name" : "John Doe"
  1013. },
  1014. {
  1015. "name" : "Jane Doe"
  1016. }
  1017. ]
  1018. }
  1019. --------------------------------------------------
  1020. // NOTCONSOLE
  1021. The wrapped processor can have a `on_failure` definition.
  1022. For example, the `id` field may not exist on all person objects.
  1023. Instead of failing the index request, you can use an `on_failure`
  1024. block to send the document to the 'failure_index' index for later inspection:
  1025. [source,js]
  1026. --------------------------------------------------
  1027. {
  1028. "foreach" : {
  1029. "field" : "persons",
  1030. "processor" : {
  1031. "remove" : {
  1032. "field" : "_value.id",
  1033. "on_failure" : [
  1034. {
  1035. "set" : {
  1036. "field", "_index",
  1037. "value", "failure_index"
  1038. }
  1039. }
  1040. ]
  1041. }
  1042. }
  1043. }
  1044. }
  1045. --------------------------------------------------
  1046. // NOTCONSOLE
  1047. In this example, if the `remove` processor does fail, then
  1048. the array elements that have been processed thus far will
  1049. be updated.
  1050. Another advanced example can be found in the {plugins}/ingest-attachment-with-arrays.html[attachment processor documentation].
  1051. [[grok-processor]]
  1052. === Grok Processor
  1053. Extracts structured fields out of a single text field within a document. You choose which field to
  1054. extract matched fields from, as well as the grok pattern you expect will match. A grok pattern is like a regular
  1055. expression that supports aliased expressions that can be reused.
  1056. This tool is perfect for syslog logs, apache and other webserver logs, mysql logs, and in general, any log format
  1057. that is generally written for humans and not computer consumption.
  1058. This processor comes packaged with many
  1059. https://github.com/elastic/elasticsearch/blob/{branch}/libs/grok/src/main/resources/patterns[reusable patterns].
  1060. If you need help building patterns to match your logs, you will find the {kibana-ref}/xpack-grokdebugger.html[Grok Debugger] tool quite useful! The Grok Debugger is an {xpack} feature under the Basic License and is therefore *free to use*. The Grok Constructor at <http://grokconstructor.appspot.com/> is also a useful tool.
  1061. [[grok-basics]]
  1062. ==== Grok Basics
  1063. Grok sits on top of regular expressions, so any regular expressions are valid in grok as well.
  1064. The regular expression library is Oniguruma, and you can see the full supported regexp syntax
  1065. https://github.com/kkos/oniguruma/blob/master/doc/RE[on the Onigiruma site].
  1066. Grok works by leveraging this regular expression language to allow naming existing patterns and combining them into more
  1067. complex patterns that match your fields.
  1068. The syntax for reusing a grok pattern comes in three forms: `%{SYNTAX:SEMANTIC}`, `%{SYNTAX}`, `%{SYNTAX:SEMANTIC:TYPE}`.
  1069. The `SYNTAX` is the name of the pattern that will match your text. For example, `3.44` will be matched by the `NUMBER`
  1070. pattern and `55.3.244.1` will be matched by the `IP` pattern. The syntax is how you match. `NUMBER` and `IP` are both
  1071. patterns that are provided within the default patterns set.
  1072. The `SEMANTIC` is the identifier you give to the piece of text being matched. For example, `3.44` could be the
  1073. duration of an event, so you could call it simply `duration`. Further, a string `55.3.244.1` might identify
  1074. the `client` making a request.
  1075. The `TYPE` is the type you wish to cast your named field. `int`, `long`, `double`, `float` and `boolean` are supported types for coercion.
  1076. For example, you might want to match the following text:
  1077. [source,txt]
  1078. --------------------------------------------------
  1079. 3.44 55.3.244.1
  1080. --------------------------------------------------
  1081. You may know that the message in the example is a number followed by an IP address. You can match this text by using the following
  1082. Grok expression.
  1083. [source,txt]
  1084. --------------------------------------------------
  1085. %{NUMBER:duration} %{IP:client}
  1086. --------------------------------------------------
  1087. [[using-grok]]
  1088. ==== Using the Grok Processor in a Pipeline
  1089. [[grok-options]]
  1090. .Grok Options
  1091. [options="header"]
  1092. |======
  1093. | Name | Required | Default | Description
  1094. | `field` | yes | - | The field to use for grok expression parsing
  1095. | `patterns` | yes | - | An ordered list of grok expression to match and extract named captures with. Returns on the first expression in the list that matches.
  1096. | `pattern_definitions` | no | - | A map of pattern-name and pattern tuples defining custom patterns to be used by the current processor. Patterns matching existing names will override the pre-existing definition.
  1097. | `trace_match` | no | false | when true, `_ingest._grok_match_index` will be inserted into your matched document's metadata with the index into the pattern found in `patterns` that matched.
  1098. | `ignore_missing` | no | false | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1099. |======
  1100. Here is an example of using the provided patterns to extract out and name structured fields from a string field in
  1101. a document.
  1102. [source,js]
  1103. --------------------------------------------------
  1104. {
  1105. "message": "55.3.244.1 GET /index.html 15824 0.043"
  1106. }
  1107. --------------------------------------------------
  1108. // NOTCONSOLE
  1109. The pattern for this could be:
  1110. [source,txt]
  1111. --------------------------------------------------
  1112. %{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}
  1113. --------------------------------------------------
  1114. Here is an example pipeline for processing the above document by using Grok:
  1115. [source,js]
  1116. --------------------------------------------------
  1117. {
  1118. "description" : "...",
  1119. "processors": [
  1120. {
  1121. "grok": {
  1122. "field": "message",
  1123. "patterns": ["%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}"]
  1124. }
  1125. }
  1126. ]
  1127. }
  1128. --------------------------------------------------
  1129. // NOTCONSOLE
  1130. This pipeline will insert these named captures as new fields within the document, like so:
  1131. [source,js]
  1132. --------------------------------------------------
  1133. {
  1134. "message": "55.3.244.1 GET /index.html 15824 0.043",
  1135. "client": "55.3.244.1",
  1136. "method": "GET",
  1137. "request": "/index.html",
  1138. "bytes": 15824,
  1139. "duration": "0.043"
  1140. }
  1141. --------------------------------------------------
  1142. // NOTCONSOLE
  1143. [[custom-patterns]]
  1144. ==== Custom Patterns
  1145. The Grok processor comes pre-packaged with a base set of pattern. These patterns may not always have
  1146. what you are looking for. Pattern have a very basic format. Each entry describes has a name and the pattern itself.
  1147. You can add your own patterns to a processor definition under the `pattern_definitions` option.
  1148. Here is an example of a pipeline specifying custom pattern definitions:
  1149. [source,js]
  1150. --------------------------------------------------
  1151. {
  1152. "description" : "...",
  1153. "processors": [
  1154. {
  1155. "grok": {
  1156. "field": "message",
  1157. "patterns": ["my %{FAVORITE_DOG:dog} is colored %{RGB:color}"],
  1158. "pattern_definitions" : {
  1159. "FAVORITE_DOG" : "beagle",
  1160. "RGB" : "RED|GREEN|BLUE"
  1161. }
  1162. }
  1163. }
  1164. ]
  1165. }
  1166. --------------------------------------------------
  1167. // NOTCONSOLE
  1168. [[trace-match]]
  1169. ==== Providing Multiple Match Patterns
  1170. Sometimes one pattern is not enough to capture the potential structure of a field. Let's assume we
  1171. want to match all messages that contain your favorite pet breeds of either cats or dogs. One way to accomplish
  1172. this is to provide two distinct patterns that can be matched, instead of one really complicated expression capturing
  1173. the same `or` behavior.
  1174. Here is an example of such a configuration executed against the simulate API:
  1175. [source,js]
  1176. --------------------------------------------------
  1177. POST _ingest/pipeline/_simulate
  1178. {
  1179. "pipeline": {
  1180. "description" : "parse multiple patterns",
  1181. "processors": [
  1182. {
  1183. "grok": {
  1184. "field": "message",
  1185. "patterns": ["%{FAVORITE_DOG:pet}", "%{FAVORITE_CAT:pet}"],
  1186. "pattern_definitions" : {
  1187. "FAVORITE_DOG" : "beagle",
  1188. "FAVORITE_CAT" : "burmese"
  1189. }
  1190. }
  1191. }
  1192. ]
  1193. },
  1194. "docs":[
  1195. {
  1196. "_source": {
  1197. "message": "I love burmese cats!"
  1198. }
  1199. }
  1200. ]
  1201. }
  1202. --------------------------------------------------
  1203. // CONSOLE
  1204. response:
  1205. [source,js]
  1206. --------------------------------------------------
  1207. {
  1208. "docs": [
  1209. {
  1210. "doc": {
  1211. "_type": "_type",
  1212. "_index": "_index",
  1213. "_id": "_id",
  1214. "_source": {
  1215. "message": "I love burmese cats!",
  1216. "pet": "burmese"
  1217. },
  1218. "_ingest": {
  1219. "timestamp": "2016-11-08T19:43:03.850+0000"
  1220. }
  1221. }
  1222. }
  1223. ]
  1224. }
  1225. --------------------------------------------------
  1226. // TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/]
  1227. Both patterns will set the field `pet` with the appropriate match, but what if we want to trace which of our
  1228. patterns matched and populated our fields? We can do this with the `trace_match` parameter. Here is the output of
  1229. that same pipeline, but with `"trace_match": true` configured:
  1230. ////
  1231. Hidden setup for example:
  1232. [source,js]
  1233. --------------------------------------------------
  1234. POST _ingest/pipeline/_simulate
  1235. {
  1236. "pipeline": {
  1237. "description" : "parse multiple patterns",
  1238. "processors": [
  1239. {
  1240. "grok": {
  1241. "field": "message",
  1242. "patterns": ["%{FAVORITE_DOG:pet}", "%{FAVORITE_CAT:pet}"],
  1243. "trace_match": true,
  1244. "pattern_definitions" : {
  1245. "FAVORITE_DOG" : "beagle",
  1246. "FAVORITE_CAT" : "burmese"
  1247. }
  1248. }
  1249. }
  1250. ]
  1251. },
  1252. "docs":[
  1253. {
  1254. "_source": {
  1255. "message": "I love burmese cats!"
  1256. }
  1257. }
  1258. ]
  1259. }
  1260. --------------------------------------------------
  1261. // CONSOLE
  1262. ////
  1263. [source,js]
  1264. --------------------------------------------------
  1265. {
  1266. "docs": [
  1267. {
  1268. "doc": {
  1269. "_type": "_type",
  1270. "_index": "_index",
  1271. "_id": "_id",
  1272. "_source": {
  1273. "message": "I love burmese cats!",
  1274. "pet": "burmese"
  1275. },
  1276. "_ingest": {
  1277. "_grok_match_index": "1",
  1278. "timestamp": "2016-11-08T19:43:03.850+0000"
  1279. }
  1280. }
  1281. }
  1282. ]
  1283. }
  1284. --------------------------------------------------
  1285. // TESTRESPONSE[s/2016-11-08T19:43:03.850\+0000/$body.docs.0.doc._ingest.timestamp/]
  1286. In the above response, you can see that the index of the pattern that matched was `"1"`. This is to say that it was the
  1287. second (index starts at zero) pattern in `patterns` to match.
  1288. This trace metadata enables debugging which of the patterns matched. This information is stored in the ingest
  1289. metadata and will not be indexed.
  1290. [[grok-processor-rest-get]]
  1291. ==== Retrieving patterns from REST endpoint
  1292. The Grok Processor comes packaged with its own REST endpoint for retrieving which patterns the processor is packaged with.
  1293. [source,js]
  1294. --------------------------------------------------
  1295. GET _ingest/processor/grok
  1296. --------------------------------------------------
  1297. // CONSOLE
  1298. The above request will return a response body containing a key-value representation of the built-in patterns dictionary.
  1299. [source,js]
  1300. --------------------------------------------------
  1301. {
  1302. "patterns" : {
  1303. "BACULA_CAPACITY" : "%{INT}{1,3}(,%{INT}{3})*",
  1304. "PATH" : "(?:%{UNIXPATH}|%{WINPATH})",
  1305. ...
  1306. }
  1307. --------------------------------------------------
  1308. // NOTCONSOLE
  1309. This can be useful to reference as the built-in patterns change across versions.
  1310. [[grok-watchdog]]
  1311. ==== Grok watchdog
  1312. Grok expressions that take too long to execute are interrupted and
  1313. the grok processor then fails with an exception. The grok
  1314. processor has a watchdog thread that determines when evaluation of
  1315. a grok expression takes too long and is controlled by the following
  1316. settings:
  1317. [[grok-watchdog-options]]
  1318. .Grok watchdog settings
  1319. [options="header"]
  1320. |======
  1321. | Name | Default | Description
  1322. | `ingest.grok.watchdog.interval` | 1s | How often to check whether there are grok evaluations that take longer than the maximum allowed execution time.
  1323. | `ingest.grok.watchdog.max_execution_time` | 1s | The maximum allowed execution of a grok expression evaluation.
  1324. |======
  1325. [[gsub-processor]]
  1326. === Gsub Processor
  1327. Converts a string field by applying a regular expression and a replacement.
  1328. If the field is not a string, the processor will throw an exception.
  1329. [[gsub-options]]
  1330. .Gsub Options
  1331. [options="header"]
  1332. |======
  1333. | Name | Required | Default | Description
  1334. | `field` | yes | - | The field to apply the replacement to
  1335. | `pattern` | yes | - | The pattern to be replaced
  1336. | `replacement` | yes | - | The string to replace the matching patterns with
  1337. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  1338. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1339. |======
  1340. [source,js]
  1341. --------------------------------------------------
  1342. {
  1343. "gsub": {
  1344. "field": "field1",
  1345. "pattern": "\.",
  1346. "replacement": "-"
  1347. }
  1348. }
  1349. --------------------------------------------------
  1350. // NOTCONSOLE
  1351. [[join-processor]]
  1352. === Join Processor
  1353. Joins each element of an array into a single string using a separator character between each element.
  1354. Throws an error when the field is not an array.
  1355. [[join-options]]
  1356. .Join Options
  1357. [options="header"]
  1358. |======
  1359. | Name | Required | Default | Description
  1360. | `field` | yes | - | The field to be separated
  1361. | `separator` | yes | - | The separator character
  1362. | `target_field` | no | `field` | The field to assign the joined value to, by default `field` is updated in-place
  1363. |======
  1364. [source,js]
  1365. --------------------------------------------------
  1366. {
  1367. "join": {
  1368. "field": "joined_array_field",
  1369. "separator": "-"
  1370. }
  1371. }
  1372. --------------------------------------------------
  1373. // NOTCONSOLE
  1374. [[json-processor]]
  1375. === JSON Processor
  1376. Converts a JSON string into a structured JSON object.
  1377. [[json-options]]
  1378. .Json Options
  1379. [options="header"]
  1380. |======
  1381. | Name | Required | Default | Description
  1382. | `field` | yes | - | The field to be parsed
  1383. | `target_field` | no | `field` | The field to insert the converted structured object into
  1384. | `add_to_root` | no | false | Flag that forces the serialized json to be injected into the top level of the document. `target_field` must not be set when this option is chosen.
  1385. |======
  1386. All JSON-supported types will be parsed (null, boolean, number, array, object, string).
  1387. Suppose you provide this configuration of the `json` processor:
  1388. [source,js]
  1389. --------------------------------------------------
  1390. {
  1391. "json" : {
  1392. "field" : "string_source",
  1393. "target_field" : "json_target"
  1394. }
  1395. }
  1396. --------------------------------------------------
  1397. // NOTCONSOLE
  1398. If the following document is processed:
  1399. [source,js]
  1400. --------------------------------------------------
  1401. {
  1402. "string_source": "{\"foo\": 2000}"
  1403. }
  1404. --------------------------------------------------
  1405. // NOTCONSOLE
  1406. after the `json` processor operates on it, it will look like:
  1407. [source,js]
  1408. --------------------------------------------------
  1409. {
  1410. "string_source": "{\"foo\": 2000}",
  1411. "json_target": {
  1412. "foo": 2000
  1413. }
  1414. }
  1415. --------------------------------------------------
  1416. // NOTCONSOLE
  1417. If the following configuration is provided, omitting the optional `target_field` setting:
  1418. [source,js]
  1419. --------------------------------------------------
  1420. {
  1421. "json" : {
  1422. "field" : "source_and_target"
  1423. }
  1424. }
  1425. --------------------------------------------------
  1426. // NOTCONSOLE
  1427. then after the `json` processor operates on this document:
  1428. [source,js]
  1429. --------------------------------------------------
  1430. {
  1431. "source_and_target": "{\"foo\": 2000}"
  1432. }
  1433. --------------------------------------------------
  1434. // NOTCONSOLE
  1435. it will look like:
  1436. [source,js]
  1437. --------------------------------------------------
  1438. {
  1439. "source_and_target": {
  1440. "foo": 2000
  1441. }
  1442. }
  1443. --------------------------------------------------
  1444. // NOTCONSOLE
  1445. This illustrates that, unless it is explicitly named in the processor configuration, the `target_field`
  1446. is the same field provided in the required `field` configuration.
  1447. [[kv-processor]]
  1448. === KV Processor
  1449. This processor helps automatically parse messages (or specific event fields) which are of the foo=bar variety.
  1450. For example, if you have a log message which contains `ip=1.2.3.4 error=REFUSED`, you can parse those automatically by configuring:
  1451. [source,js]
  1452. --------------------------------------------------
  1453. {
  1454. "kv": {
  1455. "field": "message",
  1456. "field_split": " ",
  1457. "value_split": "="
  1458. }
  1459. }
  1460. --------------------------------------------------
  1461. // NOTCONSOLE
  1462. [[kv-options]]
  1463. .Kv Options
  1464. [options="header"]
  1465. |======
  1466. | Name | Required | Default | Description
  1467. | `field` | yes | - | The field to be parsed
  1468. | `field_split` | yes | - | Regex pattern to use for splitting key-value pairs
  1469. | `value_split` | yes | - | Regex pattern to use for splitting the key from the value within a key-value pair
  1470. | `target_field` | no | `null` | The field to insert the extracted keys into. Defaults to the root of the document
  1471. | `include_keys` | no | `null` | List of keys to filter and insert into document. Defaults to including all keys
  1472. | `exclude_keys` | no | `null` | List of keys to exclude from document
  1473. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1474. |======
  1475. [[lowercase-processor]]
  1476. === Lowercase Processor
  1477. Converts a string to its lowercase equivalent.
  1478. [[lowercase-options]]
  1479. .Lowercase Options
  1480. [options="header"]
  1481. |======
  1482. | Name | Required | Default | Description
  1483. | `field` | yes | - | The field to make lowercase
  1484. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  1485. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1486. |======
  1487. [source,js]
  1488. --------------------------------------------------
  1489. {
  1490. "lowercase": {
  1491. "field": "foo"
  1492. }
  1493. }
  1494. --------------------------------------------------
  1495. // NOTCONSOLE
  1496. [[remove-processor]]
  1497. === Remove Processor
  1498. Removes existing fields. If one field doesn't exist, an exception will be thrown.
  1499. [[remove-options]]
  1500. .Remove Options
  1501. [options="header"]
  1502. |======
  1503. | Name | Required | Default | Description
  1504. | `field` | yes | - | Fields to be removed
  1505. |======
  1506. Here is an example to remove a single field:
  1507. [source,js]
  1508. --------------------------------------------------
  1509. {
  1510. "remove": {
  1511. "field": "foo"
  1512. }
  1513. }
  1514. --------------------------------------------------
  1515. // NOTCONSOLE
  1516. To remove multiple fields, you can use the following query:
  1517. [source,js]
  1518. --------------------------------------------------
  1519. {
  1520. "remove": {
  1521. "field": ["foo", "bar"]
  1522. }
  1523. }
  1524. --------------------------------------------------
  1525. // NOTCONSOLE
  1526. [[rename-processor]]
  1527. === Rename Processor
  1528. Renames an existing field. If the field doesn't exist or the new name is already used, an exception will be thrown.
  1529. [[rename-options]]
  1530. .Rename Options
  1531. [options="header"]
  1532. |======
  1533. | Name | Required | Default | Description
  1534. | `field` | yes | - | The field to be renamed
  1535. | `target_field` | yes | - | The new name of the field
  1536. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  1537. |======
  1538. [source,js]
  1539. --------------------------------------------------
  1540. {
  1541. "rename": {
  1542. "field": "foo",
  1543. "target_field": "foobar"
  1544. }
  1545. }
  1546. --------------------------------------------------
  1547. // NOTCONSOLE
  1548. [[script-processor]]
  1549. === Script Processor
  1550. Allows inline and stored scripts to be executed within ingest pipelines.
  1551. See <<modules-scripting-using, How to use scripts>> to learn more about writing scripts. The Script Processor
  1552. leverages caching of compiled scripts for improved performance. Since the
  1553. script specified within the processor is potentially re-compiled per document, it is important
  1554. to understand how script caching works. To learn more about
  1555. caching see <<modules-scripting-using-caching, Script Caching>>.
  1556. [[script-options]]
  1557. .Script Options
  1558. [options="header"]
  1559. |======
  1560. | Name | Required | Default | Description
  1561. | `lang` | no | "painless" | The scripting language
  1562. | `id` | no | - | The stored script id to refer to
  1563. | `source` | no | - | An inline script to be executed
  1564. | `params` | no | - | Script Parameters
  1565. |======
  1566. One of `id` or `source` options must be provided in order to properly reference a script to execute.
  1567. You can access the current ingest document from within the script context by using the `ctx` variable.
  1568. The following example sets a new field called `field_a_plus_b_times_c` to be the sum of two existing
  1569. numeric fields `field_a` and `field_b` multiplied by the parameter param_c:
  1570. [source,js]
  1571. --------------------------------------------------
  1572. {
  1573. "script": {
  1574. "lang": "painless",
  1575. "source": "ctx.field_a_plus_b_times_c = (ctx.field_a + ctx.field_b) * params.param_c",
  1576. "params": {
  1577. "param_c": 10
  1578. }
  1579. }
  1580. }
  1581. --------------------------------------------------
  1582. // NOTCONSOLE
  1583. It is possible to use the Script Processor to manipulate document metadata like `_index` and `_type` during
  1584. ingestion. Here is an example of an Ingest Pipeline that renames the index and type to `my_index` no matter what
  1585. was provided in the original index request:
  1586. [source,js]
  1587. --------------------------------------------------
  1588. PUT _ingest/pipeline/my_index
  1589. {
  1590. "description": "use index:my_index and type:_doc",
  1591. "processors": [
  1592. {
  1593. "script": {
  1594. "source": """
  1595. ctx._index = 'my_index';
  1596. ctx._type = '_doc';
  1597. """
  1598. }
  1599. }
  1600. ]
  1601. }
  1602. --------------------------------------------------
  1603. // CONSOLE
  1604. Using the above pipeline, we can attempt to index a document into the `any_index` index.
  1605. [source,js]
  1606. --------------------------------------------------
  1607. PUT any_index/_doc/1?pipeline=my_index
  1608. {
  1609. "message": "text"
  1610. }
  1611. --------------------------------------------------
  1612. // CONSOLE
  1613. // TEST[continued]
  1614. The response from the above index request:
  1615. [source,js]
  1616. --------------------------------------------------
  1617. {
  1618. "_index": "my_index",
  1619. "_type": "_doc",
  1620. "_id": "1",
  1621. "_version": 1,
  1622. "result": "created",
  1623. "_shards": {
  1624. "total": 2,
  1625. "successful": 1,
  1626. "failed": 0
  1627. },
  1628. "_seq_no": 0,
  1629. "_primary_term": 1,
  1630. }
  1631. --------------------------------------------------
  1632. // TESTRESPONSE
  1633. In the above response, you can see that our document was actually indexed into `my_index` instead of
  1634. `any_index`. This type of manipulation is often convenient in pipelines that have various branches of transformation,
  1635. and depending on the progress made, indexed into different indices.
  1636. [[set-processor]]
  1637. === Set Processor
  1638. Sets one field and associates it with the specified value. If the field already exists,
  1639. its value will be replaced with the provided one.
  1640. [[set-options]]
  1641. .Set Options
  1642. [options="header"]
  1643. |======
  1644. | Name | Required | Default | Description
  1645. | `field` | yes | - | The field to insert, upsert, or update
  1646. | `value` | yes | - | The value to be set for the field
  1647. | `override`| no | true | If processor will update fields with pre-existing non-null-valued field. When set to `false`, such fields will not be touched.
  1648. |======
  1649. [source,js]
  1650. --------------------------------------------------
  1651. {
  1652. "set": {
  1653. "field": "field1",
  1654. "value": 582.1
  1655. }
  1656. }
  1657. --------------------------------------------------
  1658. // NOTCONSOLE
  1659. [[split-processor]]
  1660. === Split Processor
  1661. Splits a field into an array using a separator character. Only works on string fields.
  1662. [[split-options]]
  1663. .Split Options
  1664. [options="header"]
  1665. |======
  1666. | Name | Required | Default | Description
  1667. | `field` | yes | - | The field to split
  1668. | `separator` | yes | - | A regex which matches the separator, eg `,` or `\s+`
  1669. | `target_field` | no | `field` | The field to assign the split value to, by default `field` is updated in-place
  1670. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  1671. |======
  1672. [source,js]
  1673. --------------------------------------------------
  1674. {
  1675. "split": {
  1676. "field": "my_field",
  1677. "separator": "\\s+" <1>
  1678. }
  1679. }
  1680. --------------------------------------------------
  1681. // NOTCONSOLE
  1682. <1> Treat all consecutive whitespace characters as a single separator
  1683. [[sort-processor]]
  1684. === Sort Processor
  1685. Sorts the elements of an array ascending or descending. Homogeneous arrays of numbers will be sorted
  1686. numerically, while arrays of strings or heterogeneous arrays of strings + numbers will be sorted lexicographically.
  1687. Throws an error when the field is not an array.
  1688. [[sort-options]]
  1689. .Sort Options
  1690. [options="header"]
  1691. |======
  1692. | Name | Required | Default | Description
  1693. | `field` | yes | - | The field to be sorted
  1694. | `order` | no | `"asc"` | The sort order to use. Accepts `"asc"` or `"desc"`.
  1695. | `target_field` | no | `field` | The field to assign the sorted value to, by default `field` is updated in-place
  1696. |======
  1697. [source,js]
  1698. --------------------------------------------------
  1699. {
  1700. "sort": {
  1701. "field": "field_to_sort",
  1702. "order": "desc"
  1703. }
  1704. }
  1705. --------------------------------------------------
  1706. // NOTCONSOLE
  1707. [[trim-processor]]
  1708. === Trim Processor
  1709. Trims whitespace from field.
  1710. NOTE: This only works on leading and trailing whitespace.
  1711. [[trim-options]]
  1712. .Trim Options
  1713. [options="header"]
  1714. |======
  1715. | Name | Required | Default | Description
  1716. | `field` | yes | - | The string-valued field to trim whitespace from
  1717. | `target_field` | no | `field` | The field to assign the trimmed value to, by default `field` is updated in-place
  1718. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  1719. |======
  1720. [source,js]
  1721. --------------------------------------------------
  1722. {
  1723. "trim": {
  1724. "field": "foo"
  1725. }
  1726. }
  1727. --------------------------------------------------
  1728. // NOTCONSOLE
  1729. [[uppercase-processor]]
  1730. === Uppercase Processor
  1731. Converts a string to its uppercase equivalent.
  1732. [[uppercase-options]]
  1733. .Uppercase Options
  1734. [options="header"]
  1735. |======
  1736. | Name | Required | Default | Description
  1737. | `field` | yes | - | The field to make uppercase
  1738. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  1739. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1740. |======
  1741. [source,js]
  1742. --------------------------------------------------
  1743. {
  1744. "uppercase": {
  1745. "field": "foo"
  1746. }
  1747. }
  1748. --------------------------------------------------
  1749. // NOTCONSOLE
  1750. [[dot-expand-processor]]
  1751. === Dot Expander Processor
  1752. Expands a field with dots into an object field. This processor allows fields
  1753. with dots in the name to be accessible by other processors in the pipeline.
  1754. Otherwise these <<accessing-data-in-pipelines,fields>> can't be accessed by any processor.
  1755. [[dot-expender-options]]
  1756. .Dot Expand Options
  1757. [options="header"]
  1758. |======
  1759. | Name | Required | Default | Description
  1760. | `field` | yes | - | The field to expand into an object field
  1761. | `path` | no | - | The field that contains the field to expand. Only required if the field to expand is part another object field, because the `field` option can only understand leaf fields.
  1762. |======
  1763. [source,js]
  1764. --------------------------------------------------
  1765. {
  1766. "dot_expander": {
  1767. "field": "foo.bar"
  1768. }
  1769. }
  1770. --------------------------------------------------
  1771. // NOTCONSOLE
  1772. For example the dot expand processor would turn this document:
  1773. [source,js]
  1774. --------------------------------------------------
  1775. {
  1776. "foo.bar" : "value"
  1777. }
  1778. --------------------------------------------------
  1779. // NOTCONSOLE
  1780. into:
  1781. [source,js]
  1782. --------------------------------------------------
  1783. {
  1784. "foo" : {
  1785. "bar" : "value"
  1786. }
  1787. }
  1788. --------------------------------------------------
  1789. // NOTCONSOLE
  1790. If there is already a `bar` field nested under `foo` then
  1791. this processor merges the `foo.bar` field into it. If the field is
  1792. a scalar value then it will turn that field into an array field.
  1793. For example, the following document:
  1794. [source,js]
  1795. --------------------------------------------------
  1796. {
  1797. "foo.bar" : "value2",
  1798. "foo" : {
  1799. "bar" : "value1"
  1800. }
  1801. }
  1802. --------------------------------------------------
  1803. // NOTCONSOLE
  1804. is transformed by the `dot_expander` processor into:
  1805. [source,js]
  1806. --------------------------------------------------
  1807. {
  1808. "foo" : {
  1809. "bar" : ["value1", "value2"]
  1810. }
  1811. }
  1812. --------------------------------------------------
  1813. // NOTCONSOLE
  1814. If any field outside of the leaf field conflicts with a pre-existing field of the same name,
  1815. then that field needs to be renamed first.
  1816. Consider the following document:
  1817. [source,js]
  1818. --------------------------------------------------
  1819. {
  1820. "foo": "value1",
  1821. "foo.bar": "value2"
  1822. }
  1823. --------------------------------------------------
  1824. // NOTCONSOLE
  1825. Then the `foo` needs to be renamed first before the `dot_expander`
  1826. processor is applied. So in order for the `foo.bar` field to properly
  1827. be expanded into the `bar` field under the `foo` field the following
  1828. pipeline should be used:
  1829. [source,js]
  1830. --------------------------------------------------
  1831. {
  1832. "processors" : [
  1833. {
  1834. "rename" : {
  1835. "field" : "foo",
  1836. "target_field" : "foo.bar""
  1837. }
  1838. },
  1839. {
  1840. "dot_expander": {
  1841. "field": "foo.bar"
  1842. }
  1843. }
  1844. ]
  1845. }
  1846. --------------------------------------------------
  1847. // NOTCONSOLE
  1848. The reason for this is that Ingest doesn't know how to automatically cast
  1849. a scalar field to an object field.
  1850. [[urldecode-processor]]
  1851. === URL Decode Processor
  1852. URL-decodes a string
  1853. [[urldecode-options]]
  1854. .URL Decode Options
  1855. [options="header"]
  1856. |======
  1857. | Name | Required | Default | Description
  1858. | `field` | yes | - | The field to decode
  1859. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  1860. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1861. |======
  1862. [source,js]
  1863. --------------------------------------------------
  1864. {
  1865. "urldecode": {
  1866. "field": "my_url_to_decode"
  1867. }
  1868. }
  1869. --------------------------------------------------
  1870. // NOTCONSOLE