1
0

update-datafeed.asciidoc 4.2 KB

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