put-transform.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. beta[]
  10. Instantiates a {dataframe-transform}.
  11. [discrete]
  12. [[put-data-frame-transform-request]]
  13. ==== {api-request-title}
  14. `PUT _data_frame/transforms/<data_frame_transform_id>`
  15. [discrete]
  16. [[put-data-frame-transform-prereqs]]
  17. ==== {api-prereq-title}
  18. * If the {es} {security-features} are enabled, you must have
  19. `manage_data_frame_transforms` cluster privileges to use this API. The built-in
  20. `data_frame_transforms_admin` role has these privileges. You must also
  21. have `read` and `view_index_metadata` privileges on the source index and `read`,
  22. `create_index`, and `index` privileges on the destination index. For more
  23. information, see {stack-ov}/security-privileges.html[Security privileges] and
  24. {stack-ov}/built-in-roles.html[Built-in roles].
  25. [discrete]
  26. [[put-data-frame-transform-desc]]
  27. ==== {api-description-title}
  28. IMPORTANT: You must use {kib} or this API to create a {dataframe-transform}.
  29. Do not put a {dataframe-transform} directly into any
  30. `.data-frame-internal*` indices using the Elasticsearch index API.
  31. If {es} {security-features} are enabled, do not give users any
  32. privileges on `.data-frame-internal*` indices.
  33. [discrete]
  34. [[put-data-frame-transform-path-parms]]
  35. ==== {api-path-parms-title}
  36. `<data_frame_transform_id>` (Required)::
  37. (string) Identifier for the {dataframe-transform}. This identifier can contain
  38. lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It
  39. must start and end with alphanumeric characters.
  40. [discrete]
  41. [[put-data-frame-transform-request-body]]
  42. ==== {api-request-body-title}
  43. `description` (Optional)::
  44. (string) Free text description of the {dataframe-transform}.
  45. `dest` (Required)::
  46. (object) The destination configuration, which consists of `index` and
  47. optionally a `pipeline` id. See <<data-frame-transform-dest>>.
  48. `frequency` (Optional)::
  49. (time units) The interval between checks for changes in the source indices
  50. when the {dataframe-transform} is running continuously. Defaults to `1m`.
  51. The lowest permitted value is `1s`; the highest `1h`.
  52. `pivot` (Optional)::
  53. (object) Defines the pivot function `group by` fields and the aggregation to
  54. reduce the data. See <<data-frame-transform-pivot>>.
  55. `source` (Required)::
  56. (object) The source configuration, which consists of `index` and optionally
  57. a `query`. See <<data-frame-transform-source>>.
  58. [discrete]
  59. [[put-data-frame-transform-example]]
  60. ==== {api-examples-title}
  61. [source,js]
  62. --------------------------------------------------
  63. PUT _data_frame/transforms/ecommerce_transform
  64. {
  65. "source": {
  66. "index": "kibana_sample_data_ecommerce",
  67. "query": {
  68. "term": {
  69. "geoip.continent_name": {
  70. "value": "Asia"
  71. }
  72. }
  73. }
  74. },
  75. "dest": {
  76. "index": "kibana_sample_data_ecommerce_transform",
  77. "pipeline": "add_timestamp_pipeline"
  78. },
  79. "frequency": "5m",
  80. "pivot": {
  81. "group_by": {
  82. "customer_id": {
  83. "terms": {
  84. "field": "customer_id"
  85. }
  86. }
  87. },
  88. "aggregations": {
  89. "max_price": {
  90. "max": {
  91. "field": "taxful_total_price"
  92. }
  93. }
  94. }
  95. },
  96. "description": "Maximum priced ecommerce data by customer_id in Asia"
  97. }
  98. --------------------------------------------------
  99. // CONSOLE
  100. // TEST[skip: https://github.com/elastic/elasticsearch/issues/43271]
  101. When the transform is created, you receive the following results:
  102. [source,js]
  103. ----
  104. {
  105. "acknowledged" : true
  106. }
  107. ----
  108. // TESTRESPONSE