preview-datafeed.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-preview-datafeed]]
  4. === Preview {dfeeds} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Preview {dfeeds}</titleabbrev>
  8. ++++
  9. Previews a {dfeed}.
  10. [[ml-preview-datafeed-request]]
  11. ==== {api-request-title}
  12. `GET _ml/datafeeds/<datafeed_id>/_preview`
  13. [[ml-preview-datafeed-desc]]
  14. ==== {api-description-title}
  15. The preview {dfeeds} API returns the first "page" of results from the `search`
  16. that is created by using the current {dfeed} settings. This preview shows the
  17. structure of the data that will be passed to the anomaly detection engine.
  18. [[ml-preview-datafeed-path-parms]]
  19. ==== {api-path-parms-title}
  20. `datafeed_id` (required)::
  21. (string) Identifier for the {dfeed}
  22. [[ml-preview-datafeed-prereqs]]
  23. ==== {api-prereq-title}
  24. If {es} {security-features} are enabled, you must have `monitor_ml`, `monitor`,
  25. `manage_ml`, or `manage` cluster privileges to use this API. For more
  26. information, see
  27. {stack-ov}/security-privileges.html[Security privileges].
  28. [[ml-preview-datafeed-security]]
  29. ==== Security Integration
  30. When {es} {security-features} are enabled, the {dfeed} query is previewed using
  31. the credentials of the user calling the preview {dfeed} API. When the {dfeed}
  32. is started it runs the query using the roles of the last user to
  33. create or update it. If the two sets of roles differ then the preview may
  34. not accurately reflect what the {dfeed} will return when started. To avoid
  35. such problems, the same user that creates/updates the {dfeed} should preview
  36. it to ensure it is returning the expected data.
  37. [[ml-preview-datafeed-example]]
  38. ==== {api-examples-title}
  39. The following example obtains a preview of the `datafeed-farequote` {dfeed}:
  40. [source,js]
  41. --------------------------------------------------
  42. GET _ml/datafeeds/datafeed-farequote/_preview
  43. --------------------------------------------------
  44. // CONSOLE
  45. // TEST[skip:setup:farequote_datafeed]
  46. The data that is returned for this example is as follows:
  47. [source,js]
  48. ----
  49. [
  50. {
  51. "time": 1454803200000,
  52. "airline": "JZA",
  53. "doc_count": 5,
  54. "responsetime": 990.4628295898438
  55. },
  56. {
  57. "time": 1454803200000,
  58. "airline": "JBU",
  59. "doc_count": 23,
  60. "responsetime": 877.5927124023438
  61. },
  62. {
  63. "time": 1454803200000,
  64. "airline": "KLM",
  65. "doc_count": 42,
  66. "responsetime": 1355.481201171875
  67. }
  68. ]
  69. ----
  70. // TESTRESPONSE