ingest-node.asciidoc 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642
  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. The `description` is a special field to store a helpful description of
  14. what the pipeline does.
  15. The `processors` parameter defines a list of processors to be executed in
  16. order.
  17. [[ingest-apis]]
  18. == Ingest APIs
  19. The following ingest APIs are available for managing pipelines:
  20. * <<put-pipeline-api>> to add or update a pipeline
  21. * <<get-pipeline-api>> to return a specific pipeline
  22. * <<delete-pipeline-api>> to delete a pipeline
  23. * <<simulate-pipeline-api>> to simulate a call to a pipeline
  24. [[put-pipeline-api]]
  25. === Put Pipeline API
  26. The put pipeline API adds pipelines and updates existing pipelines in the cluster.
  27. [source,js]
  28. --------------------------------------------------
  29. PUT _ingest/pipeline/my-pipeline-id
  30. {
  31. "description" : "describe pipeline",
  32. "processors" : [
  33. {
  34. "set" : {
  35. "field": "foo",
  36. "value": "bar"
  37. }
  38. }
  39. ]
  40. }
  41. --------------------------------------------------
  42. // CONSOLE
  43. NOTE: The put pipeline API also instructs all ingest nodes to reload their in-memory representation of pipelines, so that
  44. pipeline changes take effect immediately.
  45. [[get-pipeline-api]]
  46. === Get Pipeline API
  47. The get pipeline API returns pipelines based on ID. This API always returns a local reference of the pipeline.
  48. [source,js]
  49. --------------------------------------------------
  50. GET _ingest/pipeline/my-pipeline-id
  51. --------------------------------------------------
  52. // CONSOLE
  53. // TEST[continued]
  54. Example response:
  55. [source,js]
  56. --------------------------------------------------
  57. {
  58. "my-pipeline-id" : {
  59. "description" : "describe pipeline",
  60. "processors" : [
  61. {
  62. "set" : {
  63. "field" : "foo",
  64. "value" : "bar"
  65. }
  66. }
  67. ]
  68. }
  69. }
  70. --------------------------------------------------
  71. // TESTRESPONSE
  72. For each returned pipeline, the source and the version are returned.
  73. The version is useful for knowing which version of the pipeline the node has.
  74. You can specify multiple IDs to return more than one pipeline. Wildcards are also supported.
  75. [[delete-pipeline-api]]
  76. === Delete Pipeline API
  77. The delete pipeline API deletes pipelines by ID.
  78. [source,js]
  79. --------------------------------------------------
  80. DELETE _ingest/pipeline/my-pipeline-id
  81. --------------------------------------------------
  82. // CONSOLE
  83. // TEST[continued]
  84. [[simulate-pipeline-api]]
  85. === Simulate Pipeline API
  86. The simulate pipeline API executes a specific pipeline against
  87. the set of documents provided in the body of the request.
  88. You can either specify an existing pipeline to execute
  89. against the provided documents, or supply a pipeline definition in
  90. the body of the request.
  91. Here is the structure of a simulate request with a pipeline definition provided
  92. in the body of the request:
  93. [source,js]
  94. --------------------------------------------------
  95. POST _ingest/pipeline/_simulate
  96. {
  97. "pipeline" : {
  98. // pipeline definition here
  99. },
  100. "docs" : [
  101. { /** first document **/ },
  102. { /** second document **/ },
  103. // ...
  104. ]
  105. }
  106. --------------------------------------------------
  107. Here is the structure of a simulate request against an existing pipeline:
  108. [source,js]
  109. --------------------------------------------------
  110. POST _ingest/pipeline/my-pipeline-id/_simulate
  111. {
  112. "docs" : [
  113. { /** first document **/ },
  114. { /** second document **/ },
  115. // ...
  116. ]
  117. }
  118. --------------------------------------------------
  119. Here is an example of a simulate request with a pipeline defined in the request
  120. and its response:
  121. [source,js]
  122. --------------------------------------------------
  123. POST _ingest/pipeline/_simulate
  124. {
  125. "pipeline" :
  126. {
  127. "description": "_description",
  128. "processors": [
  129. {
  130. "set" : {
  131. "field" : "field2",
  132. "value" : "_value"
  133. }
  134. }
  135. ]
  136. },
  137. "docs": [
  138. {
  139. "_index": "index",
  140. "_type": "type",
  141. "_id": "id",
  142. "_source": {
  143. "foo": "bar"
  144. }
  145. },
  146. {
  147. "_index": "index",
  148. "_type": "type",
  149. "_id": "id",
  150. "_source": {
  151. "foo": "rab"
  152. }
  153. }
  154. ]
  155. }
  156. --------------------------------------------------
  157. // CONSOLE
  158. Response:
  159. [source,js]
  160. --------------------------------------------------
  161. {
  162. "docs": [
  163. {
  164. "doc": {
  165. "_id": "id",
  166. "_ttl": null,
  167. "_parent": null,
  168. "_index": "index",
  169. "_routing": null,
  170. "_type": "type",
  171. "_timestamp": null,
  172. "_source": {
  173. "field2": "_value",
  174. "foo": "bar"
  175. },
  176. "_ingest": {
  177. "timestamp": "2016-01-04T23:53:27.186+0000"
  178. }
  179. }
  180. },
  181. {
  182. "doc": {
  183. "_id": "id",
  184. "_ttl": null,
  185. "_parent": null,
  186. "_index": "index",
  187. "_routing": null,
  188. "_type": "type",
  189. "_timestamp": null,
  190. "_source": {
  191. "field2": "_value",
  192. "foo": "rab"
  193. },
  194. "_ingest": {
  195. "timestamp": "2016-01-04T23:53:27.186+0000"
  196. }
  197. }
  198. }
  199. ]
  200. }
  201. --------------------------------------------------
  202. [[ingest-verbose-param]]
  203. ==== Viewing Verbose Results
  204. You can use the simulate pipeline API to see how each processor affects the ingest document
  205. as it passes through the pipeline. To see the intermediate results of
  206. each processor in the simulate request, you can add the `verbose` parameter
  207. to the request.
  208. Here is an example of a verbose request and its response:
  209. [source,js]
  210. --------------------------------------------------
  211. POST _ingest/pipeline/_simulate?verbose
  212. {
  213. "pipeline" :
  214. {
  215. "description": "_description",
  216. "processors": [
  217. {
  218. "set" : {
  219. "field" : "field2",
  220. "value" : "_value2"
  221. }
  222. },
  223. {
  224. "set" : {
  225. "field" : "field3",
  226. "value" : "_value3"
  227. }
  228. }
  229. ]
  230. },
  231. "docs": [
  232. {
  233. "_index": "index",
  234. "_type": "type",
  235. "_id": "id",
  236. "_source": {
  237. "foo": "bar"
  238. }
  239. },
  240. {
  241. "_index": "index",
  242. "_type": "type",
  243. "_id": "id",
  244. "_source": {
  245. "foo": "rab"
  246. }
  247. }
  248. ]
  249. }
  250. --------------------------------------------------
  251. // CONSOLE
  252. Response:
  253. [source,js]
  254. --------------------------------------------------
  255. {
  256. "docs": [
  257. {
  258. "processor_results": [
  259. {
  260. "tag": "processor[set]-0",
  261. "doc": {
  262. "_id": "id",
  263. "_ttl": null,
  264. "_parent": null,
  265. "_index": "index",
  266. "_routing": null,
  267. "_type": "type",
  268. "_timestamp": null,
  269. "_source": {
  270. "field2": "_value2",
  271. "foo": "bar"
  272. },
  273. "_ingest": {
  274. "timestamp": "2016-01-05T00:02:51.383+0000"
  275. }
  276. }
  277. },
  278. {
  279. "tag": "processor[set]-1",
  280. "doc": {
  281. "_id": "id",
  282. "_ttl": null,
  283. "_parent": null,
  284. "_index": "index",
  285. "_routing": null,
  286. "_type": "type",
  287. "_timestamp": null,
  288. "_source": {
  289. "field3": "_value3",
  290. "field2": "_value2",
  291. "foo": "bar"
  292. },
  293. "_ingest": {
  294. "timestamp": "2016-01-05T00:02:51.383+0000"
  295. }
  296. }
  297. }
  298. ]
  299. },
  300. {
  301. "processor_results": [
  302. {
  303. "tag": "processor[set]-0",
  304. "doc": {
  305. "_id": "id",
  306. "_ttl": null,
  307. "_parent": null,
  308. "_index": "index",
  309. "_routing": null,
  310. "_type": "type",
  311. "_timestamp": null,
  312. "_source": {
  313. "field2": "_value2",
  314. "foo": "rab"
  315. },
  316. "_ingest": {
  317. "timestamp": "2016-01-05T00:02:51.384+0000"
  318. }
  319. }
  320. },
  321. {
  322. "tag": "processor[set]-1",
  323. "doc": {
  324. "_id": "id",
  325. "_ttl": null,
  326. "_parent": null,
  327. "_index": "index",
  328. "_routing": null,
  329. "_type": "type",
  330. "_timestamp": null,
  331. "_source": {
  332. "field3": "_value3",
  333. "field2": "_value2",
  334. "foo": "rab"
  335. },
  336. "_ingest": {
  337. "timestamp": "2016-01-05T00:02:51.384+0000"
  338. }
  339. }
  340. }
  341. ]
  342. }
  343. ]
  344. }
  345. --------------------------------------------------
  346. [[accessing-data-in-pipelines]]
  347. == Accessing Data in Pipelines
  348. The processors in a pipeline have read and write access to documents that pass through the pipeline.
  349. The processors can access fields in the source of a document and the document's metadata fields.
  350. [float]
  351. [[accessing-source-fields]]
  352. === Accessing Fields in the Source
  353. Accessing a field in the source is straightforward. You simply refer to fields by
  354. their name. For example:
  355. [source,js]
  356. --------------------------------------------------
  357. {
  358. "set": {
  359. "field": "my_field"
  360. "value": 582.1
  361. }
  362. }
  363. --------------------------------------------------
  364. On top of this, fields from the source are always accessible via the `_source` prefix:
  365. [source,js]
  366. --------------------------------------------------
  367. {
  368. "set": {
  369. "field": "_source.my_field"
  370. "value": 582.1
  371. }
  372. }
  373. --------------------------------------------------
  374. [float]
  375. [[accessing-metadata-fields]]
  376. === Accessing Metadata Fields
  377. You can access metadata fields in the same way that you access fields in the source. This
  378. is possible because Elasticsearch doesn't allow fields in the source that have the
  379. same name as metadata fields.
  380. The following example sets the `_id` metadata field of a document to `1`:
  381. [source,js]
  382. --------------------------------------------------
  383. {
  384. "set": {
  385. "field": "_id"
  386. "value": "1"
  387. }
  388. }
  389. --------------------------------------------------
  390. The following metadata fields are accessible by a processor: `_index`, `_type`, `_id`, `_routing`, `_parent`.
  391. [float]
  392. [[accessing-ingest-metadata]]
  393. === Accessing Ingest Metadata Fields
  394. Beyond metadata fields and source fields, ingest also adds ingest metadata to the documents that it processes.
  395. These metadata properties are accessible under the `_ingest` key. Currently ingest adds the ingest timestamp
  396. under the `_ingest.timestamp` key of the ingest metadata. The ingest timestamp is the time when Elasticsearch
  397. received the index or bulk request to pre-process the document.
  398. Any processor can add ingest-related metadata during document processing. Ingest metadata is transient
  399. and is lost after a document has been processed by the pipeline. Therefore, ingest metadata won't be indexed.
  400. The following example adds a field with the name `received`. The value is the ingest timestamp:
  401. [source,js]
  402. --------------------------------------------------
  403. {
  404. "set": {
  405. "field": "received"
  406. "value": "{{_ingest.timestamp}}"
  407. }
  408. }
  409. --------------------------------------------------
  410. Unlike Elasticsearch metadata fields, the ingest metadata field name `_ingest` can be used as a valid field name
  411. in the source of a document. Use `_source._ingest` to refer to the field in the source document. Otherwise, `_ingest`
  412. will be interpreted as an ingest metadata field.
  413. [float]
  414. [[accessing-template-fields]]
  415. === Accessing Fields and Metafields in Templates
  416. A number of processor settings also support templating. Settings that support templating can have zero or more
  417. template snippets. A template snippet begins with `{{` and ends with `}}`.
  418. Accessing fields and metafields in templates is exactly the same as via regular processor field settings.
  419. The following example adds a field named `field_c`. Its value is a concatenation of
  420. the values of `field_a` and `field_b`.
  421. [source,js]
  422. --------------------------------------------------
  423. {
  424. "set": {
  425. "field": "field_c"
  426. "value": "{{field_a}} {{field_b}}"
  427. }
  428. }
  429. --------------------------------------------------
  430. The following example uses the value of the `geoip.country_iso_code` field in the source
  431. to set the index that the document will be indexed into:
  432. [source,js]
  433. --------------------------------------------------
  434. {
  435. "set": {
  436. "field": "_index"
  437. "value": "{{geoip.country_iso_code}}"
  438. }
  439. }
  440. --------------------------------------------------
  441. [[handling-failure-in-pipelines]]
  442. == Handling Failures in Pipelines
  443. In its simplest use case, a pipeline defines a list of processors that
  444. are executed sequentially, and processing halts at the first exception. This
  445. behavior may not be desirable when failures are expected. For example, you may have logs
  446. that don't match the specified grok expression. Instead of halting execution, you may
  447. want to index such documents into a separate index.
  448. To enable this behavior, you can use the `on_failure` parameter. The `on_failure` parameter
  449. defines a list of processors to be executed immediately following the failed processor.
  450. You can specify this parameter at the pipeline level, as well as at the processor
  451. level. If a processor specifies an `on_failure` configuration, whether
  452. it is empty or not, any exceptions that are thrown by the processor are caught, and the
  453. pipeline continues executing the remaining processors. Because you can define further processors
  454. within the scope of an `on_failure` statement, you can nest failure handling.
  455. The following example defines a pipeline that renames the `foo` field in
  456. the processed document to `bar`. If the document does not contain the `foo` field, the processor
  457. attaches an error message to the document for later analysis within
  458. Elasticsearch.
  459. [source,js]
  460. --------------------------------------------------
  461. {
  462. "description" : "my first pipeline with handled exceptions",
  463. "processors" : [
  464. {
  465. "rename" : {
  466. "field" : "foo",
  467. "target_field" : "bar",
  468. "on_failure" : [
  469. {
  470. "set" : {
  471. "field" : "error",
  472. "value" : "field \"foo\" does not exist, cannot rename to \"bar\""
  473. }
  474. }
  475. ]
  476. }
  477. }
  478. ]
  479. }
  480. --------------------------------------------------
  481. The following example defines an `on_failure` block on a whole pipeline to change
  482. the index to which failed documents get sent.
  483. [source,js]
  484. --------------------------------------------------
  485. {
  486. "description" : "my first pipeline with handled exceptions",
  487. "processors" : [ ... ],
  488. "on_failure" : [
  489. {
  490. "set" : {
  491. "field" : "_index",
  492. "value" : "failed-{{ _index }}"
  493. }
  494. }
  495. ]
  496. }
  497. --------------------------------------------------
  498. Alternatively instead of defining behaviour in case of processor failure, it is also possible
  499. to ignore a failure and continue with the next processor by specifying the `ignore_failure` setting.
  500. In case in the example below the field `foo` doesn't exist the failure will be caught and the pipeline
  501. continues to execute, which in this case means that the pipeline does nothing.
  502. [source,js]
  503. --------------------------------------------------
  504. {
  505. "description" : "my first pipeline with handled exceptions",
  506. "processors" : [
  507. {
  508. "rename" : {
  509. "field" : "foo",
  510. "target_field" : "bar",
  511. "ignore_failure" : true
  512. }
  513. }
  514. ]
  515. }
  516. --------------------------------------------------
  517. The `ignore_failure` can be set on any processor and defaults to `false`.
  518. [float]
  519. [[accessing-error-metadata]]
  520. === Accessing Error Metadata From Processors Handling Exceptions
  521. You may want to retrieve the actual error message that was thrown
  522. by a failed processor. To do so you can access metadata fields called
  523. `on_failure_message`, `on_failure_processor_type`, and `on_failure_processor_tag`. These fields are only accessible
  524. from within the context of an `on_failure` block.
  525. Here is an updated version of the example that you
  526. saw earlier. But instead of setting the error message manually, the example leverages the `on_failure_message`
  527. metadata field to provide the error message.
  528. [source,js]
  529. --------------------------------------------------
  530. {
  531. "description" : "my first pipeline with handled exceptions",
  532. "processors" : [
  533. {
  534. "rename" : {
  535. "field" : "foo",
  536. "to" : "bar",
  537. "on_failure" : [
  538. {
  539. "set" : {
  540. "field" : "error",
  541. "value" : "{{ _ingest.on_failure_message }}"
  542. }
  543. }
  544. ]
  545. }
  546. }
  547. ]
  548. }
  549. --------------------------------------------------
  550. [[ingest-processors]]
  551. == Processors
  552. All processors are defined in the following way within a pipeline definition:
  553. [source,js]
  554. --------------------------------------------------
  555. {
  556. "PROCESSOR_NAME" : {
  557. ... processor configuration options ...
  558. }
  559. }
  560. --------------------------------------------------
  561. Each processor defines its own configuration parameters, but all processors have
  562. the ability to declare `tag` and `on_failure` fields. These fields are optional.
  563. A `tag` is simply a string identifier of the specific instantiation of a certain
  564. processor in a pipeline. The `tag` field does not affect the processor's behavior,
  565. but is very useful for bookkeeping and tracing errors to specific processors.
  566. See <<handling-failure-in-pipelines>> to learn more about the `on_failure` field and error handling in pipelines.
  567. The <<ingest-info,node info API>> can be used to figure out what processors are available in a cluster.
  568. The <<ingest-info,node info API>> will provide a per node list of what processors are available.
  569. Custom processors must be installed on all nodes. The put pipeline API will fail if a processor specified in a pipeline
  570. doesn't exist on all nodes. If you rely on custom processor plugins make sure to mark these plugins as mandatory by adding
  571. `plugin.mandatory` setting to the `config/elasticsearch.yml` file, for example:
  572. [source,yaml]
  573. --------------------------------------------------
  574. plugin.mandatory: ingest-attachment,ingest-geoip
  575. --------------------------------------------------
  576. A node will not start if either of these plugins are not available.
  577. The <<ingest-stats,node stats API>> can be used to fetch ingest usage statistics, globally and on a per
  578. pipeline basis. Useful to find out which pipelines are used the most or spent the most time on preprocessing.
  579. [[append-processor]]
  580. === Append Processor
  581. Appends one or more values to an existing array if the field already exists and it is an array.
  582. Converts a scalar to an array and appends one or more values to it if the field exists and it is a scalar.
  583. Creates an array containing the provided values if the field doesn't exist.
  584. Accepts a single value or an array of values.
  585. [[append-options]]
  586. .Append Options
  587. [options="header"]
  588. |======
  589. | Name | Required | Default | Description
  590. | `field` | yes | - | The field to be appended to
  591. | `value` | yes | - | The value to be appended
  592. |======
  593. [source,js]
  594. --------------------------------------------------
  595. {
  596. "append": {
  597. "field": "field1"
  598. "value": ["item2", "item3", "item4"]
  599. }
  600. }
  601. --------------------------------------------------
  602. [[convert-processor]]
  603. === Convert Processor
  604. Converts an existing field's value to a different type, such as converting a string to an integer.
  605. If the field value is an array, all members will be converted.
  606. The supported types include: `integer`, `float`, `string`, `boolean`, and `auto`.
  607. Specifying `boolean` will set the field to true if its string value is equal to `true` (ignore case), to
  608. false if its string value is equal to `false` (ignore case), or it will throw an exception otherwise.
  609. Specifying `auto` will attempt to convert the string-valued `field` into the closest non-string type.
  610. For example, a field whose value is `"true"` will be converted to its respective boolean type: `true`. And
  611. a value of `"242.15"` will "automatically" be converted to `242.15` of type `float`. If a provided field cannot
  612. be appropriately converted, the Convert Processor will still process successfully and leave the field value as-is. In
  613. such a case, `target_field` will still be updated with the unconverted field value.
  614. [[convert-options]]
  615. .Convert Options
  616. [options="header"]
  617. |======
  618. | Name | Required | Default | Description
  619. | `field` | yes | - | The field whose value is to be converted
  620. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  621. | `type` | yes | - | The type to convert the existing value to
  622. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  623. |======
  624. [source,js]
  625. --------------------------------------------------
  626. {
  627. "convert": {
  628. "field" : "foo"
  629. "type": "integer"
  630. }
  631. }
  632. --------------------------------------------------
  633. [[date-processor]]
  634. === Date Processor
  635. Parses dates from fields, and then uses the date or timestamp as the timestamp for the document.
  636. By default, the date processor adds the parsed date as a new field called `@timestamp`. You can specify a
  637. different field by setting the `target_field` configuration parameter. Multiple date formats are supported
  638. as part of the same date processor definition. They will be used sequentially to attempt parsing the date field,
  639. in the same order they were defined as part of the processor definition.
  640. [[date-options]]
  641. .Date options
  642. [options="header"]
  643. |======
  644. | Name | Required | Default | Description
  645. | `field` | yes | - | The field to get the date from.
  646. | `target_field` | no | @timestamp | The field that will hold the parsed date.
  647. | `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.
  648. | `timezone` | no | UTC | The timezone to use when parsing the date.
  649. | `locale` | no | ENGLISH | The locale to use when parsing the date, relevant when parsing month names or week days.
  650. |======
  651. Here is an example that adds the parsed date to the `timestamp` field based on the `initial_date` field:
  652. [source,js]
  653. --------------------------------------------------
  654. {
  655. "description" : "...",
  656. "processors" : [
  657. {
  658. "date" : {
  659. "field" : "initial_date",
  660. "target_field" : "timestamp",
  661. "formats" : ["dd/MM/yyyy hh:mm:ss"],
  662. "timezone" : "Europe/Amsterdam"
  663. }
  664. }
  665. ]
  666. }
  667. --------------------------------------------------
  668. [[date-index-name-processor]]
  669. === Date Index Name Processor
  670. The purpose of this processor is to point documents to the right time based index based
  671. on a date or timestamp field in a document by using the <<date-math-index-names, date math index name support>>.
  672. The processor sets the `_index` meta field with a date math index name expression based on the provided index name
  673. prefix, a date or timestamp field in the documents being processed and the provided date rounding.
  674. First, this processor fetches the date or timestamp from a field in the document being processed. Optionally,
  675. date formatting can be configured on how the field's value should be parsed into a date. Then this date,
  676. the provided index name prefix and the provided date rounding get formatted into a date math index name expression.
  677. Also here optionally date formatting can be specified on how the date should be formatted into a date math index name
  678. expression.
  679. An example pipeline that points documents to a monthly index that starts with a `myindex-` prefix based on a
  680. date in the `date1` field:
  681. [source,js]
  682. --------------------------------------------------
  683. PUT _ingest/pipeline/monthlyindex
  684. {
  685. "description": "monthly date-time index naming",
  686. "processors" : [
  687. {
  688. "date_index_name" : {
  689. "field" : "date1",
  690. "index_name_prefix" : "myindex-",
  691. "date_rounding" : "M"
  692. }
  693. }
  694. ]
  695. }
  696. --------------------------------------------------
  697. // CONSOLE
  698. Using that pipeline for an index request:
  699. [source,js]
  700. --------------------------------------------------
  701. PUT /myindex/type/1?pipeline=monthlyindex
  702. {
  703. "date1" : "2016-04-25T12:02:01.789Z"
  704. }
  705. --------------------------------------------------
  706. // CONSOLE
  707. // TEST[continued]
  708. [source,js]
  709. --------------------------------------------------
  710. {
  711. "_index" : "myindex-2016-04-01",
  712. "_type" : "type",
  713. "_id" : "1",
  714. "_version" : 1,
  715. "result" : "created",
  716. "_shards" : {
  717. "total" : 2,
  718. "successful" : 1,
  719. "failed" : 0
  720. },
  721. "created" : true
  722. }
  723. --------------------------------------------------
  724. // TESTRESPONSE
  725. The above request will not index this document into the `myindex` index, but into the `myindex-2016-04-01` index because
  726. it was rounded by month. This is because the date-index-name-processor overrides the `_index` property of the document.
  727. To see the date-math value of the index supplied in the actual index request which resulted in the above document being
  728. indexed into `myindex-2016-04-01` we can inspect the effects of the processor using a simulate request.
  729. [source,js]
  730. --------------------------------------------------
  731. POST _ingest/pipeline/_simulate
  732. {
  733. "pipeline" :
  734. {
  735. "description": "monthly date-time index naming",
  736. "processors" : [
  737. {
  738. "date_index_name" : {
  739. "field" : "date1",
  740. "index_name_prefix" : "myindex-",
  741. "date_rounding" : "M"
  742. }
  743. }
  744. ]
  745. },
  746. "docs": [
  747. {
  748. "_source": {
  749. "date1": "2016-04-25T12:02:01.789Z"
  750. }
  751. }
  752. ]
  753. }
  754. --------------------------------------------------
  755. // CONSOLE
  756. and the result:
  757. [source,js]
  758. --------------------------------------------------
  759. {
  760. "docs" : [
  761. {
  762. "doc" : {
  763. "_id" : "_id",
  764. "_index" : "<myindex-{2016-04-25||/M{yyyy-MM-dd|UTC}}>",
  765. "_type" : "_type",
  766. "_source" : {
  767. "date1" : "2016-04-25T12:02:01.789Z"
  768. },
  769. "_ingest" : {
  770. "timestamp" : "2016-08-11T12:00:01.222Z"
  771. }
  772. }
  773. }
  774. ]
  775. }
  776. --------------------------------------------------
  777. // TESTRESPONSE[s/2016-08-11T12:00:01.222Z/$body.docs.0.doc._ingest.timestamp/]
  778. The above example shows that `_index` was set to `<myindex-{2016-04-25||/M{yyyy-MM-dd|UTC}}>`. Elasticsearch
  779. understands this to mean `2016-04-01` as is explained in the <<date-math-index-names, date math index name documentation>>
  780. [[date-index-name-options]]
  781. .Date index name options
  782. [options="header"]
  783. |======
  784. | Name | Required | Default | Description
  785. | `field` | yes | - | The field to get the date or timestamp from.
  786. | `index_name_prefix` | no | - | A prefix of the index name to be prepended before the printed date.
  787. | `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).
  788. | `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.
  789. | `timezone` | no | UTC | The timezone to use when parsing the date and when date math index supports resolves expressions into concrete index names.
  790. | `locale` | no | ENGLISH | The locale to use when parsing the date from the document being preprocessed, relevant when parsing month names or week days.
  791. | `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.
  792. |======
  793. [[fail-processor]]
  794. === Fail Processor
  795. Raises an exception. This is useful for when
  796. you expect a pipeline to fail and want to relay a specific message
  797. to the requester.
  798. [[fail-options]]
  799. .Fail Options
  800. [options="header"]
  801. |======
  802. | Name | Required | Default | Description
  803. | `message` | yes | - | The error message of the `FailException` thrown by the processor
  804. |======
  805. [source,js]
  806. --------------------------------------------------
  807. {
  808. "fail": {
  809. "message": "an error message"
  810. }
  811. }
  812. --------------------------------------------------
  813. [[foreach-processor]]
  814. === Foreach Processor
  815. experimental[This processor may change or be replaced by something else that provides similar functionality. This
  816. processor executes in its own context, which makes it different compared to all other processors and for features like
  817. verbose simulation the subprocessor isn't visible. The reason we still expose this processor, is that it is the only
  818. processor that can operate on an array]
  819. Processes elements in an array of unknown length.
  820. All processors can operate on elements inside an array, but if all elements of an array need to
  821. be processed in the same way, defining a processor for each element becomes cumbersome and tricky
  822. because it is likely that the number of elements in an array is unknown. For this reason the `foreach`
  823. processor exists. By specifying the field holding array elements and a processor that
  824. defines what should happen to each element, array fields can easily be preprocessed.
  825. A processor inside the foreach processor works in the array element context and puts that in the ingest metadata
  826. under the `_ingest._value` key. If the array element is a json object it holds all immediate fields of that json object.
  827. and if the nested object is a value is `_ingest._value` just holds that value. Note that if a processor prior to the
  828. `foreach` processor used `_ingest._value` key then the specified value will not be available to the processor inside
  829. the `foreach` processor. The `foreach` processor does restore the original value, so that value is available to processors
  830. after the `foreach` processor.
  831. Note that any other field from the document are accessible and modifiable like with all other processors. This processor
  832. just puts the current array element being read into `_ingest._value` ingest metadata attribute, so that it may be
  833. pre-processed.
  834. If the `foreach` processor fails to process an element inside the array, and no `on_failure` processor has been specified,
  835. then it aborts the execution and leaves the array unmodified.
  836. [[foreach-options]]
  837. .Foreach Options
  838. [options="header"]
  839. |======
  840. | Name | Required | Default | Description
  841. | `field` | yes | - | The array field
  842. | `processor` | yes | - | The processor to execute against each field
  843. |======
  844. Assume the following document:
  845. [source,js]
  846. --------------------------------------------------
  847. {
  848. "values" : ["foo", "bar", "baz"]
  849. }
  850. --------------------------------------------------
  851. When this `foreach` processor operates on this sample document:
  852. [source,js]
  853. --------------------------------------------------
  854. {
  855. "foreach" : {
  856. "field" : "values",
  857. "processor" : {
  858. "uppercase" : {
  859. "field" : "_ingest._value"
  860. }
  861. }
  862. }
  863. }
  864. --------------------------------------------------
  865. Then the document will look like this after preprocessing:
  866. [source,js]
  867. --------------------------------------------------
  868. {
  869. "values" : ["FOO", "BAR", "BAZ"]
  870. }
  871. --------------------------------------------------
  872. Let's take a look at another example:
  873. [source,js]
  874. --------------------------------------------------
  875. {
  876. "persons" : [
  877. {
  878. "id" : "1",
  879. "name" : "John Doe"
  880. },
  881. {
  882. "id" : "2",
  883. "name" : "Jane Doe"
  884. }
  885. ]
  886. }
  887. --------------------------------------------------
  888. In this case, the `id` field needs to be removed,
  889. so the following `foreach` processor is used:
  890. [source,js]
  891. --------------------------------------------------
  892. {
  893. "foreach" : {
  894. "field" : "persons",
  895. "processor" : {
  896. "remove" : {
  897. "field" : "_ingest._value.id"
  898. }
  899. }
  900. }
  901. }
  902. --------------------------------------------------
  903. After preprocessing the result is:
  904. [source,js]
  905. --------------------------------------------------
  906. {
  907. "persons" : [
  908. {
  909. "name" : "John Doe"
  910. },
  911. {
  912. "name" : "Jane Doe"
  913. }
  914. ]
  915. }
  916. --------------------------------------------------
  917. The wrapped processor can have a `on_failure` definition.
  918. For example, the `id` field may not exist on all person objects.
  919. Instead of failing the index request, you can use an `on_failure`
  920. block to send the document to the 'failure_index' index for later inspection:
  921. [source,js]
  922. --------------------------------------------------
  923. {
  924. "foreach" : {
  925. "field" : "persons",
  926. "processor" : {
  927. "remove" : {
  928. "field" : "_value.id",
  929. "on_failure" : [
  930. {
  931. "set" : {
  932. "field", "_index",
  933. "value", "failure_index"
  934. }
  935. }
  936. ]
  937. }
  938. }
  939. }
  940. }
  941. --------------------------------------------------
  942. In this example, if the `remove` processor does fail, then
  943. the array elements that have been processed thus far will
  944. be updated.
  945. [[grok-processor]]
  946. === Grok Processor
  947. Extracts structured fields out of a single text field within a document. You choose which field to
  948. extract matched fields from, as well as the grok pattern you expect will match. A grok pattern is like a regular
  949. expression that supports aliased expressions that can be reused.
  950. This tool is perfect for syslog logs, apache and other webserver logs, mysql logs, and in general, any log format
  951. that is generally written for humans and not computer consumption.
  952. This processor comes packaged with over
  953. https://github.com/elastic/elasticsearch/tree/master/modules/ingest-common/src/main/resources/patterns[120 reusable patterns].
  954. If you need help building patterns to match your logs, you will find the <http://grokdebug.herokuapp.com> and
  955. <http://grokconstructor.appspot.com/> applications quite useful!
  956. [[grok-basics]]
  957. ==== Grok Basics
  958. Grok sits on top of regular expressions, so any regular expressions are valid in grok as well.
  959. The regular expression library is Oniguruma, and you can see the full supported regexp syntax
  960. https://github.com/kkos/oniguruma/blob/master/doc/RE[on the Onigiruma site].
  961. Grok works by leveraging this regular expression language to allow naming existing patterns and combining them into more
  962. complex patterns that match your fields.
  963. The syntax for reusing a grok pattern comes in three forms: `%{SYNTAX:SEMANTIC}`, `%{SYNTAX}`, `%{SYNTAX:SEMANTIC:TYPE}`.
  964. The `SYNTAX` is the name of the pattern that will match your text. For example, `3.44` will be matched by the `NUMBER`
  965. pattern and `55.3.244.1` will be matched by the `IP` pattern. The syntax is how you match. `NUMBER` and `IP` are both
  966. patterns that are provided within the default patterns set.
  967. The `SEMANTIC` is the identifier you give to the piece of text being matched. For example, `3.44` could be the
  968. duration of an event, so you could call it simply `duration`. Further, a string `55.3.244.1` might identify
  969. the `client` making a request.
  970. The `TYPE` is the type you wish to cast your named field. `int` and `float` are currently the only types supported for coercion.
  971. For example, you might want to match the following text:
  972. [source,js]
  973. --------------------------------------------------
  974. 3.44 55.3.244.1
  975. --------------------------------------------------
  976. 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
  977. Grok expression.
  978. [source,js]
  979. --------------------------------------------------
  980. %{NUMBER:duration} %{IP:client}
  981. --------------------------------------------------
  982. [[using-grok]]
  983. ==== Using the Grok Processor in a Pipeline
  984. [[grok-options]]
  985. .Grok Options
  986. [options="header"]
  987. |======
  988. | Name | Required | Default | Description
  989. | `field` | yes | - | The field to use for grok expression parsing
  990. | `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.
  991. | `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.
  992. | `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.
  993. | `ignore_missing` | no | false | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  994. |======
  995. Here is an example of using the provided patterns to extract out and name structured fields from a string field in
  996. a document.
  997. [source,js]
  998. --------------------------------------------------
  999. {
  1000. "message": "55.3.244.1 GET /index.html 15824 0.043"
  1001. }
  1002. --------------------------------------------------
  1003. The pattern for this could be:
  1004. [source,js]
  1005. --------------------------------------------------
  1006. %{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}
  1007. --------------------------------------------------
  1008. Here is an example pipeline for processing the above document by using Grok:
  1009. [source,js]
  1010. --------------------------------------------------
  1011. {
  1012. "description" : "...",
  1013. "processors": [
  1014. {
  1015. "grok": {
  1016. "field": "message",
  1017. "patterns": ["%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}"]
  1018. }
  1019. }
  1020. ]
  1021. }
  1022. --------------------------------------------------
  1023. This pipeline will insert these named captures as new fields within the document, like so:
  1024. [source,js]
  1025. --------------------------------------------------
  1026. {
  1027. "message": "55.3.244.1 GET /index.html 15824 0.043",
  1028. "client": "55.3.244.1",
  1029. "method": "GET",
  1030. "request": "/index.html",
  1031. "bytes": 15824,
  1032. "duration": "0.043"
  1033. }
  1034. --------------------------------------------------
  1035. [[custom-patterns]]
  1036. ==== Custom Patterns and Pattern Files
  1037. The Grok processor comes pre-packaged with a base set of pattern. These patterns may not always have
  1038. what you are looking for. Pattern have a very basic format. Each entry describes has a name and the pattern itself.
  1039. You can add your own patterns to a processor definition under the `pattern_definitions` option.
  1040. Here is an example of a pipeline specifying custom pattern definitions:
  1041. [source,js]
  1042. --------------------------------------------------
  1043. {
  1044. "description" : "...",
  1045. "processors": [
  1046. {
  1047. "grok": {
  1048. "field": "message",
  1049. "patterns": ["my %{FAVORITE_DOG:dog} is colored %{RGB:color}"]
  1050. "pattern_definitions" : {
  1051. "FAVORITE_DOG" : "beagle",
  1052. "RGB" : "RED|GREEN|BLUE"
  1053. }
  1054. }
  1055. }
  1056. ]
  1057. }
  1058. --------------------------------------------------
  1059. [[gsub-processor]]
  1060. === Gsub Processor
  1061. Converts a string field by applying a regular expression and a replacement.
  1062. If the field is not a string, the processor will throw an exception.
  1063. [[gsub-options]]
  1064. .Gsub Options
  1065. [options="header"]
  1066. |======
  1067. | Name | Required | Default | Description
  1068. | `field` | yes | - | The field to apply the replacement to
  1069. | `pattern` | yes | - | The pattern to be replaced
  1070. | `replacement` | yes | - | The string to replace the matching patterns with
  1071. |======
  1072. [source,js]
  1073. --------------------------------------------------
  1074. {
  1075. "gsub": {
  1076. "field": "field1",
  1077. "pattern": "\.",
  1078. "replacement": "-"
  1079. }
  1080. }
  1081. --------------------------------------------------
  1082. [[join-processor]]
  1083. === Join Processor
  1084. Joins each element of an array into a single string using a separator character between each element.
  1085. Throws an error when the field is not an array.
  1086. [[join-options]]
  1087. .Join Options
  1088. [options="header"]
  1089. |======
  1090. | Name | Required | Default | Description
  1091. | `field` | yes | - | The field to be separated
  1092. | `separator` | yes | - | The separator character
  1093. |======
  1094. [source,js]
  1095. --------------------------------------------------
  1096. {
  1097. "join": {
  1098. "field": "joined_array_field",
  1099. "separator": "-"
  1100. }
  1101. }
  1102. --------------------------------------------------
  1103. [[json-processor]]
  1104. === JSON Processor
  1105. Converts a JSON string into a structured JSON object.
  1106. [[json-options]]
  1107. .Json Options
  1108. [options="header"]
  1109. |======
  1110. | Name | Required | Default | Description
  1111. | `field` | yes | - | The field to be parsed
  1112. | `target_field` | no | `field` | The field to insert the converted structured object into
  1113. |======
  1114. [source,js]
  1115. --------------------------------------------------
  1116. {
  1117. "json": {
  1118. "field": "{\"foo\": 2000}"
  1119. }
  1120. }
  1121. --------------------------------------------------
  1122. [[lowercase-processor]]
  1123. === Lowercase Processor
  1124. Converts a string to its lowercase equivalent.
  1125. [[lowercase-options]]
  1126. .Lowercase Options
  1127. [options="header"]
  1128. |======
  1129. | Name | Required | Default | Description
  1130. | `field` | yes | - | The field to make lowercase
  1131. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1132. |======
  1133. [source,js]
  1134. --------------------------------------------------
  1135. {
  1136. "lowercase": {
  1137. "field": "foo"
  1138. }
  1139. }
  1140. --------------------------------------------------
  1141. [[remove-processor]]
  1142. === Remove Processor
  1143. Removes an existing field. If the field doesn't exist, an exception will be thrown.
  1144. [[remove-options]]
  1145. .Remove Options
  1146. [options="header"]
  1147. |======
  1148. | Name | Required | Default | Description
  1149. | `field` | yes | - | The field to be removed
  1150. |======
  1151. [source,js]
  1152. --------------------------------------------------
  1153. {
  1154. "remove": {
  1155. "field": "foo"
  1156. }
  1157. }
  1158. --------------------------------------------------
  1159. [[rename-processor]]
  1160. === Rename Processor
  1161. Renames an existing field. If the field doesn't exist or the new name is already used, an exception will be thrown.
  1162. [[rename-options]]
  1163. .Rename Options
  1164. [options="header"]
  1165. |======
  1166. | Name | Required | Default | Description
  1167. | `field` | yes | - | The field to be renamed
  1168. | `target_field` | yes | - | The new name of the field
  1169. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  1170. |======
  1171. [source,js]
  1172. --------------------------------------------------
  1173. {
  1174. "rename": {
  1175. "field": "foo",
  1176. "target_field": "foobar"
  1177. }
  1178. }
  1179. --------------------------------------------------
  1180. [[script-processor]]
  1181. === Script Processor
  1182. Allows inline, stored, and file scripts to be executed within ingest pipelines.
  1183. See <<modules-scripting-using, How to use scripts>> to learn more about writing scripts. The Script Processor
  1184. leverages caching of compiled scripts for improved performance. Since the
  1185. script specified within the processor is potentially re-compiled per document, it is important
  1186. to understand how script caching works. To learn more about
  1187. caching see <<modules-scripting-using-caching, Script Caching>>.
  1188. [[script-options]]
  1189. .Script Options
  1190. [options="header"]
  1191. |======
  1192. | Name | Required | Default | Description
  1193. | `lang` | no | - | The scripting language
  1194. | `file` | no | - | The script file to refer to
  1195. | `id` | no | - | The stored script id to refer to
  1196. | `inline` | no | - | An inline script to be executed
  1197. | `params` | no | - | Script Parameters
  1198. |======
  1199. You can access the current ingest document from within the script context by using the `ctx` variable.
  1200. The following example sets a new field called `field_a_plus_b_times_c` to be the sum of two existing
  1201. numeric fields `field_a` and `field_b` multiplied by the parameter param_c:
  1202. [source,js]
  1203. --------------------------------------------------
  1204. {
  1205. "script": {
  1206. "lang": "painless",
  1207. "inline": "ctx.field_a_plus_b_times_c = (ctx.field_a + ctx.field_b) * params.param_c",
  1208. "params": {
  1209. "param_c": 10
  1210. }
  1211. }
  1212. }
  1213. --------------------------------------------------
  1214. [[set-processor]]
  1215. === Set Processor
  1216. Sets one field and associates it with the specified value. If the field already exists,
  1217. its value will be replaced with the provided one.
  1218. [[set-options]]
  1219. .Set Options
  1220. [options="header"]
  1221. |======
  1222. | Name | Required | Default | Description
  1223. | `field` | yes | - | The field to insert, upsert, or update
  1224. | `value` | yes | - | The value to be set for the field
  1225. | `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.
  1226. |======
  1227. [source,js]
  1228. --------------------------------------------------
  1229. {
  1230. "set": {
  1231. "field": "field1",
  1232. "value": 582.1
  1233. }
  1234. }
  1235. --------------------------------------------------
  1236. [[split-processor]]
  1237. === Split Processor
  1238. Splits a field into an array using a separator character. Only works on string fields.
  1239. [[split-options]]
  1240. .Split Options
  1241. [options="header"]
  1242. |======
  1243. | Name | Required | Default | Description
  1244. | `field` | yes | - | The field to split
  1245. | `separator` | yes | - | A regex which matches the separator, eg `,` or `\s+`
  1246. |======
  1247. [source,js]
  1248. --------------------------------------------------
  1249. {
  1250. "split": {
  1251. "field": "my_field",
  1252. "separator": "\\s+" <1>
  1253. }
  1254. }
  1255. --------------------------------------------------
  1256. <1> Treat all consecutive whitespace characters as a single separator
  1257. [[sort-processor]]
  1258. === Sort Processor
  1259. Sorts the elements of an array ascending or descending. Homogeneous arrays of numbers will be sorted
  1260. numerically, while arrays of strings or heterogeneous arrays of strings + numbers will be sorted lexicographically.
  1261. Throws an error when the field is not an array.
  1262. [[sort-options]]
  1263. .Sort Options
  1264. [options="header"]
  1265. |======
  1266. | Name | Required | Default | Description
  1267. | `field` | yes | - | The field to be sorted
  1268. | `order` | no | `"asc"` | The sort order to use. Accepts `"asc"` or `"desc"`.
  1269. |======
  1270. [source,js]
  1271. --------------------------------------------------
  1272. {
  1273. "sort": {
  1274. "field": "field_to_sort",
  1275. "order": "desc"
  1276. }
  1277. }
  1278. --------------------------------------------------
  1279. [[trim-processor]]
  1280. === Trim Processor
  1281. Trims whitespace from field.
  1282. NOTE: This only works on leading and trailing whitespace.
  1283. [[trim-options]]
  1284. .Trim Options
  1285. [options="header"]
  1286. |======
  1287. | Name | Required | Default | Description
  1288. | `field` | yes | - | The string-valued field to trim whitespace from
  1289. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  1290. |======
  1291. [source,js]
  1292. --------------------------------------------------
  1293. {
  1294. "trim": {
  1295. "field": "foo"
  1296. }
  1297. }
  1298. --------------------------------------------------
  1299. [[uppercase-processor]]
  1300. === Uppercase Processor
  1301. Converts a string to its uppercase equivalent.
  1302. [[uppercase-options]]
  1303. .Uppercase Options
  1304. [options="header"]
  1305. |======
  1306. | Name | Required | Default | Description
  1307. | `field` | yes | - | The field to make uppercase
  1308. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  1309. |======
  1310. [source,js]
  1311. --------------------------------------------------
  1312. {
  1313. "uppercase": {
  1314. "field": "foo"
  1315. }
  1316. }
  1317. --------------------------------------------------
  1318. [[dot-expand-processor]]
  1319. === Dot Expander Processor
  1320. Expands a field with dots into an object field. This processor allows fields
  1321. with dots in the name to be accessible by other processors in the pipeline.
  1322. Otherwise these <<accessing-data-in-pipelines,fields> can't be accessed by any processor.
  1323. [[dot-expender-options]]
  1324. .Dot Expand Options
  1325. [options="header"]
  1326. |======
  1327. | Name | Required | Default | Description
  1328. | `field` | yes | - | The field to expand into an object field
  1329. | `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.
  1330. |======
  1331. [source,js]
  1332. --------------------------------------------------
  1333. {
  1334. "dot_expander": {
  1335. "field": "foo.bar"
  1336. }
  1337. }
  1338. --------------------------------------------------
  1339. For example the dot expand processor would turn this document:
  1340. [source,js]
  1341. --------------------------------------------------
  1342. {
  1343. "foo.bar" : "value"
  1344. }
  1345. --------------------------------------------------
  1346. into:
  1347. [source,js]
  1348. --------------------------------------------------
  1349. {
  1350. "foo" : {
  1351. "bar" : "value"
  1352. }
  1353. }
  1354. --------------------------------------------------
  1355. If there is already a `bar` field nested under `foo` then
  1356. this processor merges the the `foo.bar` field into it. If the field is
  1357. a scalar value then it will turn that field into an array field.
  1358. For example, the following document:
  1359. [source,js]
  1360. --------------------------------------------------
  1361. {
  1362. "foo.bar" : "value2",
  1363. "foo" : {
  1364. "bar" : "value1"
  1365. }
  1366. }
  1367. --------------------------------------------------
  1368. is transformed by the `dot_expander` processor into:
  1369. [source,js]
  1370. --------------------------------------------------
  1371. {
  1372. "foo" : {
  1373. "bar" : ["value1", "value2"]
  1374. }
  1375. }
  1376. --------------------------------------------------
  1377. If any field outside of the leaf field conflicts with a pre-existing field of the same name,
  1378. then that field needs to be renamed first.
  1379. Consider the following document:
  1380. [source,js]
  1381. --------------------------------------------------
  1382. {
  1383. "foo": "value1",
  1384. "foo.bar": "value2"
  1385. }
  1386. --------------------------------------------------
  1387. Then the the `foo` needs to be renamed first before the `dot_expander`
  1388. processor is applied. So in order for the `foo.bar` field to properly
  1389. be expanded into the `bar` field under the `foo` field the following
  1390. pipeline should be used:
  1391. [source,js]
  1392. --------------------------------------------------
  1393. {
  1394. "processors" : [
  1395. {
  1396. "rename" : {
  1397. "field" : "foo",
  1398. "target_field" : "foo.bar""
  1399. }
  1400. },
  1401. {
  1402. "dot_expander": {
  1403. "field": "foo.bar"
  1404. }
  1405. }
  1406. ]
  1407. }
  1408. --------------------------------------------------
  1409. The reason for this is that Ingest doesn't know how to automatically cast
  1410. a scalar field to an object field.