update-datafeed.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-update-datafeed]]
  4. === Update {dfeeds} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Update {dfeeds}</titleabbrev>
  8. ++++
  9. Updates certain properties of a {dfeed}.
  10. [[ml-update-datafeed-request]]
  11. ==== {api-request-title}
  12. `POST _ml/datafeeds/<feed_id>/_update`
  13. [[ml-update-datafeed-prereqs]]
  14. ==== {api-prereq-title}
  15. * If {es} {security-features} are enabled, you must have `manage_ml`, or `manage`
  16. cluster privileges to use this API. See
  17. <<security-privileges>>.
  18. [[ml-update-datafeed-desc]]
  19. ==== {api-description-title}
  20. If you update a {dfeed} property, you must stop and start the {dfeed} for the
  21. change to be applied.
  22. IMPORTANT: When {es} {security-features} are enabled, your {dfeed} remembers
  23. which roles the user who updated it had at the time of update and runs the query
  24. using those same roles.
  25. [[ml-update-datafeed-path-parms]]
  26. ==== {api-path-parms-title}
  27. `<feed_id>`::
  28. (Required, string)
  29. include::{docdir}/ml/ml-shared.asciidoc[tag=datafeed-id]
  30. [[ml-update-datafeed-request-body]]
  31. ==== {api-request-body-title}
  32. The following properties can be updated after the {dfeed} is created:
  33. `aggregations`::
  34. (Optional, object)
  35. include::{docdir}/ml/ml-shared.asciidoc[tag=aggregations]
  36. `chunking_config`::
  37. (Optional, object)
  38. include::{docdir}/ml/ml-shared.asciidoc[tag=chunking-config]
  39. `delayed_data_check_config`::
  40. (Optional, object)
  41. include::{docdir}/ml/ml-shared.asciidoc[tag=delayed-data-check-config]
  42. `frequency`::
  43. (Optional, <<time-units, time units>>)
  44. include::{docdir}/ml/ml-shared.asciidoc[tag=frequency]
  45. `indices`::
  46. (Optional, array)
  47. include::{docdir}/ml/ml-shared.asciidoc[tag=indices]
  48. `max_empty_searches`::
  49. (Optional, integer)
  50. include::{docdir}/ml/ml-shared.asciidoc[tag=max-empty-searches]
  51. +
  52. --
  53. The special value `-1` unsets this setting.
  54. --
  55. `query`::
  56. (Optional, object)
  57. include::{docdir}/ml/ml-shared.asciidoc[tag=query]
  58. +
  59. --
  60. WARNING: If you change the query, the analyzed data is also changed. Therefore,
  61. the required time to learn might be long and the understandability of the
  62. results is unpredictable. If you want to make significant changes to the source
  63. data, we would recommend you clone it and create a second job containing the
  64. amendments. Let both run in parallel and close one when you are satisfied with
  65. the results of the other job.
  66. --
  67. `query_delay`::
  68. (Optional, <<time-units, time units>>)
  69. include::{docdir}/ml/ml-shared.asciidoc[tag=query-delay]
  70. `script_fields`::
  71. (Optional, object)
  72. include::{docdir}/ml/ml-shared.asciidoc[tag=script-fields]
  73. `scroll_size`::
  74. (Optional, unsigned integer)
  75. include::{docdir}/ml/ml-shared.asciidoc[tag=scroll-size]
  76. [[ml-update-datafeed-example]]
  77. ==== {api-examples-title}
  78. The following example updates the query for the `datafeed-total-requests`
  79. {dfeed} so that only log entries of error level are analyzed:
  80. [source,console]
  81. --------------------------------------------------
  82. POST _ml/datafeeds/datafeed-total-requests/_update
  83. {
  84. "query": {
  85. "term": {
  86. "level": "error"
  87. }
  88. }
  89. }
  90. --------------------------------------------------
  91. // TEST[skip:setup:server_metrics_datafeed]
  92. When the {dfeed} is updated, you receive the full {dfeed} configuration with
  93. with the updated values:
  94. [source,console-result]
  95. ----
  96. {
  97. "datafeed_id": "datafeed-total-requests",
  98. "job_id": "total-requests",
  99. "query_delay": "83474ms",
  100. "indices": ["server-metrics"],
  101. "query": {
  102. "term": {
  103. "level": {
  104. "value": "error",
  105. "boost": 1.0
  106. }
  107. }
  108. },
  109. "scroll_size": 1000,
  110. "chunking_config": {
  111. "mode": "auto"
  112. }
  113. }
  114. ----
  115. // TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]