put-transform.asciidoc 5.5 KB

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