preview-datafeed.asciidoc 2.0 KB

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