put-transform.asciidoc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[put-data-frame-transform]]
  4. === Create {dataframe-transforms} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {dataframe-transforms}</titleabbrev>
  8. ++++
  9. Instantiates a {dataframe-transform}.
  10. beta[]
  11. [[put-data-frame-transform-request]]
  12. ==== {api-request-title}
  13. `PUT _data_frame/transforms/<data_frame_transform_id>`
  14. [[put-data-frame-transform-prereqs]]
  15. ==== {api-prereq-title}
  16. * If the {es} {security-features} are enabled, you must have
  17. `manage_data_frame_transforms` cluster privileges to use this API. The built-in
  18. `data_frame_transforms_admin` role has these privileges. You must also
  19. have `read` and `view_index_metadata` privileges on the source index and `read`,
  20. `create_index`, and `index` privileges on the destination index. For more
  21. information, see {stack-ov}/security-privileges.html[Security privileges] and
  22. {stack-ov}/built-in-roles.html[Built-in roles].
  23. [[put-data-frame-transform-desc]]
  24. ==== {api-description-title}
  25. When the {dataframe-transform} is created, a series of validations occur to
  26. ensure its success. For example, there is a check for the existence of the
  27. source indices and a check that the destination index is not part of the source
  28. index pattern. You can use the `defer_validation` parameter to skip these
  29. checks.
  30. IMPORTANT: You must use {kib} or this API to create a {dataframe-transform}.
  31. Do not put a {dataframe-transform} directly into any
  32. `.data-frame-internal*` indices using the Elasticsearch index API.
  33. If {es} {security-features} are enabled, do not give users any
  34. privileges on `.data-frame-internal*` indices.
  35. [[put-data-frame-transform-path-parms]]
  36. ==== {api-path-parms-title}
  37. `<data_frame_transform_id>`::
  38. (Required, string) Identifier for the {dataframe-transform}. This identifier
  39. can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and
  40. underscores. It must start and end with alphanumeric characters.
  41. [[put-data-frame-transform-query-parms]]
  42. ==== {api-query-parms-title}
  43. `defer_validation`::
  44. (Optional, boolean) When `true`, deferrable validations are not run. This
  45. behavior may be desired if the source index does not exist until after the
  46. {dataframe-transform} is created. Deferred validations are always run when the
  47. {dataframe-transform} is started, with the exception of privilege checks. If
  48. the user who created the transform does not have the required privileges on
  49. the source and destination indices, the transform starts but then fails when
  50. it attempts the unauthorized operation. The default value is `false`.
  51. [[put-data-frame-transform-request-body]]
  52. ==== {api-request-body-title}
  53. `description`::
  54. (Optional, string) Free text description of the {dataframe-transform}.
  55. `dest`::
  56. (Required, object) Required. The destination configuration, which has the
  57. following properties:
  58. `index`:::
  59. (Required, string) The _destination index_ for the {dataframe-transform}.
  60. `pipeline`:::
  61. (Optional, string) The unique identifier for a <<pipeline,pipeline>>.
  62. `frequency`::
  63. (Optional, time units) The interval between checks for changes in the source
  64. indices when the {dataframe-transform} is running continuously. Also determines
  65. the retry interval in the event of transient failures while the {dataframe-transform} is
  66. searching or indexing. The minimum value is `1s` and the maximum is `1h`. The
  67. default value is `1m`.
  68. `pivot`::
  69. (Required, object) Defines the pivot function `group by` fields and the aggregation to
  70. reduce the data. See <<data-frame-transform-pivot>>.
  71. `source`::
  72. (Required, object) The source configuration, which has the following
  73. properties:
  74. `index`:::
  75. (Required, string or array) The _source indices_ for the
  76. {dataframe-transform}. It can be a single index, an index pattern (for
  77. example, `"myindex*"`), or an array of indices (for example,
  78. `["index1", "index2"]`).
  79. `query`:::
  80. (Optional, object) A query clause that retrieves a subset of data from the
  81. source index. See <<query-dsl>>.
  82. `sync`::
  83. (Optional, object) Defines the properties required to run continuously.
  84. `time`:::
  85. (Required, object) Specifies that the {dataframe-transform} uses a time
  86. field to synchronize the source and destination indices.
  87. `field`::::
  88. (Required, string) The date field that is used to identify new documents
  89. in the source.
  90. +
  91. --
  92. TIP: In general, it’s a good idea to use a field that contains the
  93. <<accessing-ingest-metadata,ingest timestamp>>. If you use a different field,
  94. you might need to set the `delay` such that it accounts for data transmission
  95. delays.
  96. --
  97. `delay`::::
  98. (Optional, time units) The time delay between the current time and the
  99. latest input data time. The default value is `60s`.
  100. [[put-data-frame-transform-example]]
  101. ==== {api-examples-title}
  102. [source,js]
  103. --------------------------------------------------
  104. PUT _data_frame/transforms/ecommerce_transform
  105. {
  106. "source": {
  107. "index": "kibana_sample_data_ecommerce",
  108. "query": {
  109. "term": {
  110. "geoip.continent_name": {
  111. "value": "Asia"
  112. }
  113. }
  114. }
  115. },
  116. "pivot": {
  117. "group_by": {
  118. "customer_id": {
  119. "terms": {
  120. "field": "customer_id"
  121. }
  122. }
  123. },
  124. "aggregations": {
  125. "max_price": {
  126. "max": {
  127. "field": "taxful_total_price"
  128. }
  129. }
  130. }
  131. },
  132. "description": "Maximum priced ecommerce data by customer_id in Asia",
  133. "dest": {
  134. "index": "kibana_sample_data_ecommerce_transform",
  135. "pipeline": "add_timestamp_pipeline"
  136. },
  137. "frequency": "5m",
  138. "sync": {
  139. "time": {
  140. "field": "order_date",
  141. "delay": "60s"
  142. }
  143. }
  144. }
  145. --------------------------------------------------
  146. // CONSOLE
  147. // TEST[setup:kibana_sample_data_ecommerce]
  148. When the transform is created, you receive the following results:
  149. [source,js]
  150. ----
  151. {
  152. "acknowledged" : true
  153. }
  154. ----
  155. // TESTRESPONSE