原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-preview-datafeed.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/ml-preview-datafeed.html

Preview datafeeds APIedit

Previews a datafeed.

Requestedit

GET _ml/datafeeds/<datafeed_id>/_preview

Prerequisitesedit

  • If Elasticsearch security features are enabled, you must have monitor_ml, monitor, manage_ml, or manage cluster privileges to use this API. See Security privileges.

Descriptionedit

The preview datafeeds API returns the first "page" of results from the search that is created by using the current datafeed settings. This preview shows the structure of the data that will be passed to the anomaly detection engine.

When Elasticsearch security features are enabled, the datafeed query is previewed using the credentials of the user calling the preview datafeed API. When the datafeed is started it runs the query using the roles of the last user to create or update it. If the two sets of roles differ then the preview may not accurately reflect what the datafeed will return when started. To avoid such problems, the same user that creates/updates the datafeed should preview it to ensure it is returning the expected data.

Path parametersedit

<datafeed_id>
(Required, string) A numerical character string that uniquely identifies the datafeed. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric characters.

Examplesedit

GET _ml/datafeeds/datafeed-high_sum_total_sales/_preview

The data that is returned for this example is as follows:

[
  {
    "order_date" : 1575504259000,
    "category.keyword" : "Men's Clothing",
    "customer_full_name.keyword" : "Sultan Al Benson",
    "taxful_total_price" : 35.96875
  },
  {
    "order_date" : 1575504518000,
    "category.keyword" : [
      "Women's Accessories",
      "Women's Clothing"
    ],
    "customer_full_name.keyword" : "Pia Webb",
    "taxful_total_price" : 83.0
  },
  {
    "order_date" : 1575505382000,
    "category.keyword" : [
      "Women's Accessories",
      "Women's Shoes"
    ],
    "customer_full_name.keyword" : "Brigitte Graham",
    "taxful_total_price" : 72.0
  },
  ...
]