preview-datafeed.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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-prereqs]]
  14. ==== {api-prereq-title}
  15. * If {es} {security-features} are enabled, you must have `monitor_ml`, `monitor`,
  16. `manage_ml`, or `manage` cluster privileges to use this API. See
  17. <<security-privileges>>.
  18. [[ml-preview-datafeed-desc]]
  19. ==== {api-description-title}
  20. The preview {dfeeds} API returns the first "page" of results from the `search`
  21. that is created by using the current {dfeed} settings. This preview shows the
  22. structure of the data that will be passed to the anomaly detection engine.
  23. IMPORTANT: When {es} {security-features} are enabled, the {dfeed} query is
  24. previewed using the credentials of the user calling the preview {dfeed} API.
  25. When the {dfeed} is started it runs the query using the roles of the last user
  26. to 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. [[ml-preview-datafeed-path-parms]]
  31. ==== {api-path-parms-title}
  32. `<datafeed_id>`::
  33. (Required, string) Identifier for the {dfeed}.
  34. [[ml-preview-datafeed-example]]
  35. ==== {api-examples-title}
  36. The following example obtains a preview of the `datafeed-farequote` {dfeed}:
  37. [source,console]
  38. --------------------------------------------------
  39. GET _ml/datafeeds/datafeed-farequote/_preview
  40. --------------------------------------------------
  41. // TEST[skip:setup:farequote_datafeed]
  42. The data that is returned for this example is as follows:
  43. [source,console-result]
  44. ----
  45. [
  46. {
  47. "time": 1454803200000,
  48. "airline": "JZA",
  49. "doc_count": 5,
  50. "responsetime": 990.4628295898438
  51. },
  52. {
  53. "time": 1454803200000,
  54. "airline": "JBU",
  55. "doc_count": 23,
  56. "responsetime": 877.5927124023438
  57. },
  58. {
  59. "time": 1454803200000,
  60. "airline": "KLM",
  61. "doc_count": 42,
  62. "responsetime": 1355.481201171875
  63. }
  64. ]
  65. ----