update-datafeed.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. {stack-ov}/security-privileges.html[Security privileges].
  18. [[ml-update-datafeed-desc]]
  19. ==== {api-description-title}
  20. If you update the `delayed_data_check_config` property, you must stop and
  21. start the {dfeed} for the 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>` (Required)::
  28. (string) Identifier for the {dfeed}.
  29. [[ml-update-datafeed-request-body]]
  30. ==== {api-request-body-title}
  31. The following properties can be updated after the {dfeed} is created:
  32. `aggregations` (Optional)::
  33. (object) If set, the {dfeed} performs aggregation searches.
  34. For more information, see <<ml-datafeed-resource>>.
  35. `chunking_config` (Optional)::
  36. (object) Specifies how data searches are split into time chunks.
  37. See <<ml-datafeed-chunking-config>>.
  38. `delayed_data_check_config` (Optional)::
  39. (object) Specifies whether the data feed checks for missing data and
  40. the size of the window. See <<ml-datafeed-delayed-data-check-config>>.
  41. `frequency` (Optional)::
  42. (time units) The interval at which scheduled queries are made while the
  43. {dfeed} runs in real time. The default value is either the bucket span for short
  44. bucket spans, or, for longer bucket spans, a sensible fraction of the bucket
  45. span. For example: `150s`.
  46. `indices` (Optional)::
  47. (array) An array of index names. Wildcards are supported. For example:
  48. `["it_ops_metrics", "server*"]`.
  49. `job_id` (Optional)::
  50. (string) A numerical character string that uniquely identifies the job.
  51. `query` (Optional)::
  52. (object) The {es} query domain-specific language (DSL). This value
  53. corresponds to the query object in an {es} search POST body. All the
  54. options that are supported by {es} can be used, as this object is
  55. passed verbatim to {es}. By default, this property has the following
  56. value: `{"match_all": {"boost": 1}}`.
  57. `query_delay` (Optional)::
  58. (time units) The number of seconds behind real-time that data is queried. For
  59. example, if data from 10:04 a.m. might not be searchable in {es} until
  60. 10:06 a.m., set this property to 120 seconds. The default value is `60s`.
  61. `script_fields` (Optional)::
  62. (object) Specifies scripts that evaluate custom expressions and returns
  63. script fields to the {dfeed}.
  64. The <<ml-detectorconfig,detector configuration objects>> in a job can contain
  65. functions that use these script fields.
  66. For more information,
  67. see {ref}/search-request-script-fields.html[Script Fields].
  68. `scroll_size` (Optional)::
  69. (unsigned integer) The `size` parameter that is used in {es} searches.
  70. The default value is `1000`.
  71. For more information about these properties,
  72. see <<ml-datafeed-resource>>.
  73. [[ml-update-datafeed-example]]
  74. ==== {api-examples-title}
  75. The following example updates the query for the `datafeed-total-requests`
  76. {dfeed} so that only log entries of error level are analyzed:
  77. [source,js]
  78. --------------------------------------------------
  79. POST _ml/datafeeds/datafeed-total-requests/_update
  80. {
  81. "query": {
  82. "term": {
  83. "level": "error"
  84. }
  85. }
  86. }
  87. --------------------------------------------------
  88. // CONSOLE
  89. // TEST[skip:setup:server_metrics_datafeed]
  90. When the {dfeed} is updated, you receive the full {dfeed} configuration with
  91. with the updated values:
  92. [source,js]
  93. ----
  94. {
  95. "datafeed_id": "datafeed-total-requests",
  96. "job_id": "total-requests",
  97. "query_delay": "83474ms",
  98. "indices": ["server-metrics"],
  99. "query": {
  100. "term": {
  101. "level": {
  102. "value": "error",
  103. "boost": 1.0
  104. }
  105. }
  106. },
  107. "scroll_size": 1000,
  108. "chunking_config": {
  109. "mode": "auto"
  110. }
  111. }
  112. ----
  113. // TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]