preview-datafeed.asciidoc 2.0 KB

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