update-datafeed.asciidoc 3.8 KB

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