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>`::
  28. (Required, 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`::
  33. (Optional, object) If set, the {dfeed} performs aggregation searches. For more
  34. information, see <<ml-datafeed-resource>>.
  35. `chunking_config`::
  36. (Optional, object) Specifies how data searches are split into time chunks. See
  37. <<ml-datafeed-chunking-config>>.
  38. `delayed_data_check_config`::
  39. (Optional, 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`::
  42. (Optional, <<time-units, time units>>) The interval at which scheduled queries
  43. are made while the {dfeed} runs in real time. The default value is either the
  44. bucket span for short bucket spans, or, for longer bucket spans, a sensible
  45. fraction of the bucket span. For example: `150s`.
  46. `indices`::
  47. (Optional, array) An array of index names. Wildcards are supported. For
  48. example: `["it_ops_metrics", "server*"]`.
  49. `job_id`::
  50. (Optional, string) A numerical character string that uniquely identifies the
  51. {anomaly-job}.
  52. `query`::
  53. (Optional, object) The {es} query domain-specific language (DSL). This value
  54. corresponds to the query object in an {es} search POST body. All the options
  55. that are supported by {es} can be used, as this object is passed verbatim to
  56. {es}. By default, this property has the following value:
  57. `{"match_all": {"boost": 1}}`.
  58. `query_delay`::
  59. (Optional, <<time-units, time units>>) The number of seconds behind real-time
  60. that data is queried. For example, if data from 10:04 a.m. might not be
  61. searchable in {es} until 10:06 a.m., set this property to 120 seconds. The
  62. default value is `60s`.
  63. `script_fields`::
  64. (Optional, object) Specifies scripts that evaluate custom expressions and
  65. returns script fields to the {dfeed}. The
  66. <<ml-detectorconfig,detector configuration objects>> in a job can contain
  67. functions that use these script fields. For more information, see
  68. <<request-body-search-script-fields,Script fields>>.
  69. `scroll_size`::
  70. (Optional, unsigned integer) The `size` parameter that is used in {es}
  71. searches. The default value is `1000`.
  72. For more information about these properties,
  73. see <<ml-datafeed-resource>>.
  74. [[ml-update-datafeed-example]]
  75. ==== {api-examples-title}
  76. The following example updates the query for the `datafeed-total-requests`
  77. {dfeed} so that only log entries of error level are analyzed:
  78. [source,console]
  79. --------------------------------------------------
  80. POST _ml/datafeeds/datafeed-total-requests/_update
  81. {
  82. "query": {
  83. "term": {
  84. "level": "error"
  85. }
  86. }
  87. }
  88. --------------------------------------------------
  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,console-result]
  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/]