1
0

update-datafeed.asciidoc 3.8 KB

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