update-datafeed.asciidoc 3.9 KB

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