put-datafeed.asciidoc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-put-datafeed]]
  4. === Create {dfeeds} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {dfeeds}</titleabbrev>
  8. ++++
  9. Instantiates a {dfeed}.
  10. [[ml-put-datafeed-request]]
  11. ==== {api-request-title}
  12. `PUT _ml/datafeeds/<feed_id>`
  13. [[ml-put-datafeed-prereqs]]
  14. ==== {api-prereq-title}
  15. * You must create an {anomaly-job} before you create a {dfeed}.
  16. * If {es} {security-features} are enabled, you must have `manage_ml` or `manage`
  17. cluster privileges to use this API. See
  18. <<security-privileges>>.
  19. [[ml-put-datafeed-desc]]
  20. ==== {api-description-title}
  21. You can associate only one {dfeed} to each {anomaly-job}.
  22. [IMPORTANT]
  23. ====
  24. * You must use {kib} or this API to create a {dfeed}. Do not put a
  25. {dfeed} directly to the `.ml-config` index using the {es} index API. If {es}
  26. {security-features} are enabled, do not give users `write` privileges on the
  27. `.ml-config` index.
  28. * When {es} {security-features} are enabled, your {dfeed} remembers which roles
  29. the user who created it had at the time of creation and runs the query using
  30. those same roles.
  31. ====
  32. [[ml-put-datafeed-path-parms]]
  33. ==== {api-path-parms-title}
  34. `<feed_id>`::
  35. (Required, string)
  36. include::{docdir}/ml/ml-shared.asciidoc[tag=datafeed-id]
  37. [[ml-put-datafeed-request-body]]
  38. ==== {api-request-body-title}
  39. `aggregations`::
  40. (Optional, object)
  41. include::{docdir}/ml/ml-shared.asciidoc[tag=aggregations]
  42. `chunking_config`::
  43. (Optional, object)
  44. include::{docdir}/ml/ml-shared.asciidoc[tag=chunking-config]
  45. `delayed_data_check_config`::
  46. (Optional, object)
  47. include::{docdir}/ml/ml-shared.asciidoc[tag=delayed-data-check-config]
  48. `frequency`::
  49. (Optional, <<time-units, time units>>)
  50. include::{docdir}/ml/ml-shared.asciidoc[tag=frequency]
  51. `indices`::
  52. (Required, array)
  53. include::{docdir}/ml/ml-shared.asciidoc[tag=indices]
  54. `job_id`::
  55. (Required, string)
  56. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  57. `max_empty_searches`::
  58. (Optional,integer)
  59. include::{docdir}/ml/ml-shared.asciidoc[tag=max-empty-searches]
  60. `query`::
  61. (Optional, object)
  62. include::{docdir}/ml/ml-shared.asciidoc[tag=query]
  63. `query_delay`::
  64. (Optional, <<time-units, time units>>)
  65. include::{docdir}/ml/ml-shared.asciidoc[tag=query-delay]
  66. `script_fields`::
  67. (Optional, object)
  68. include::{docdir}/ml/ml-shared.asciidoc[tag=script-fields]
  69. `scroll_size`::
  70. (Optional, unsigned integer)
  71. include::{docdir}/ml/ml-shared.asciidoc[tag=scroll-size]
  72. [[ml-put-datafeed-example]]
  73. ==== {api-examples-title}
  74. [source,console]
  75. --------------------------------------------------
  76. PUT _ml/datafeeds/datafeed-total-requests
  77. {
  78. "job_id": "total-requests",
  79. "indices": ["server-metrics"]
  80. }
  81. --------------------------------------------------
  82. // TEST[skip:setup:server_metrics_job]
  83. When the {dfeed} is created, you receive the following results:
  84. [source,console-result]
  85. ----
  86. {
  87. "datafeed_id": "datafeed-total-requests",
  88. "job_id": "total-requests",
  89. "query_delay": "83474ms",
  90. "indices": [
  91. "server-metrics"
  92. ],
  93. "query": {
  94. "match_all": {
  95. "boost": 1.0
  96. }
  97. },
  98. "scroll_size": 1000,
  99. "chunking_config": {
  100. "mode": "auto"
  101. }
  102. }
  103. ----
  104. // TESTRESPONSE[s/"query_delay": "83474ms"/"query_delay": $body.query_delay/]
  105. // TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]