Link Search Menu Expand Document Documentation Menu

预测 API

使用这些操作以编程方式创建和管理预测器,用于生成时间序列数据的预测。


目录


创建预测器

于 3.1 版本引入

创建一个用于生成时间序列预测的预测器。预测器可以是单流(不带类别字段)或高基数(带一个或多个类别字段)。

创建预测器时,您需要定义源索引、预测间隔和范围、要预测的特征,以及可选参数(例如类别字段和自定义结果索引)。

端点

POST _plugins/_forecast/forecasters

请求正文字段

此 API 支持以下请求正文字段。

字段 数据类型 必需 描述
名称 字符串 必需 预测器名称。
description 字符串 可选 预测器的自由格式描述。
时间字段 字符串 必需 源文档的时间戳字段。
索引 字符串或字符串数组 必需 一个或多个源索引或索引别名。
feature_attributes 对象数组 必需 要预测的特征。仅支持一个特征。每个对象必须包含 feature_nameaggregation_query
forecast_interval 对象 必需 生成预测的间隔。
horizon 整数 可选 要预测的未来间隔数量。
window_delay 对象 可选 为考虑摄入延迟而添加的延迟。
category_field 字符串 可选 用于按实体分组预测的一个或两个字段。
result_index 字符串 可选 用于存储预测结果的自定义索引别名。必须以 opensearch-forecast-result- 开头。默认为 opensearch-forecast-results
suggested_seasonality 整数 可选 按间隔计算的季节性模式长度。预期范围:8–256。
recency_emphasis 整数 可选 控制近期数据对预测的影响程度。默认为 2560
history 整数 可选 用于模型训练的过去间隔数量。
result_index_min_size 整数 可选 触发索引翻转所需的最小主分片大小(以 MB 为单位)。
result_index_min_age 整数 可选 触发索引翻转所需的最小索引年龄(以天为单位)。
result_index_ttl 整数 可选 翻转索引在删除前所需的最小时间量(以天为单位)。
flatten_custom_result_index 布尔型 可选 如果为 true,则在自定义结果索引中扁平化嵌套字段以便于聚合。
瓦片大小 整数 可选 用于影响预测的过去间隔数量。默认为 8。推荐范围:4–128。

请求示例:单流预测器

以下示例为 network-requests 索引创建了一个单流预测器。该预测器每 3 分钟预测一次 deny 字段的最大值,使用前 300 个间隔进行训练。window_delay 设置通过将预测窗口延迟 3 分钟来考虑摄入延迟

POST _plugins/_forecast/forecasters
{
    "name": "Second-Test-Forecaster-7",
    "description": "ok rate",
    "time_field": "@timestamp",
    "indices": [
        "network-requests"
    ],
    "feature_attributes": [
        {
            "feature_id": "deny_max",
            "feature_name": "deny max",
            "feature_enabled": true,
            "importance": 1,
            "aggregation_query": {
                "deny_max": {
                    "max": {
                        "field": "deny"
                    }
                }
            }
        }
    ],
    "window_delay": {
        "period": {
            "interval": 3,
            "unit": "MINUTES"
        }
    },
    "forecast_interval": {
        "period": {
            "interval": 3,
            "unit": "MINUTES"
        }
    },
    "schema_version": 2,
    "horizon": 3,
    "history": 300
}

示例响应

{
  "_id": "4WnXAYoBU2pVBal92lXD",
  "_version": 1,
  "forecaster": {
    "...": "Configuration (omitted)"
  }
}

请求示例:高基数预测器

以下示例创建了一个高基数预测器,它按 host_nest.host2 字段对预测进行分组。与单流示例类似,它使用历史数据以 3 分钟的间隔预测 deny 字段的最大值。此设置支持跨不同主机的实体特定预测

POST _plugins/_forecast/forecasters
{
    "name": "Second-Test-Forecaster-7",
    "description": "ok rate",
    "time_field": "@timestamp",
    "indices": [
        "network-requests"
    ],
    "feature_attributes": [
        {
            "feature_id": "deny_max",
            "feature_name": "deny max",
            "feature_enabled": true,
            "importance": 1,
            "aggregation_query": {
                "deny_max": {
                    "max": {
                        "field": "deny"
                    }
                }
            }
        }
    ],
    "window_delay": {
        "period": {
            "interval": 3,
            "unit": "MINUTES"
        }
    },
    "forecast_interval": {
        "period": {
            "interval": 3,
            "unit": "MINUTES"
        }
    },
    "schema_version": 2,
    "horizon": 3,
    "history": 300,
    "category_field": ["host_nest.host2"],
}

示例响应

{
  "_id": "4WnXAYoBU2pVBal92lXD",
  "_version": 1,
  "forecaster": {
    "...": "Configuration (omitted)"
  }
}

验证预测器

于 3.1 版本引入

使用此 API 验证预测器配置是否有效。您可以执行两种类型的验证:

  • 仅配置验证:检查配置是否语法正确并引用了现有字段。
  • 训练可行性验证:执行全面验证以确保预测器可以使用指定的配置进行训练。

端点

以下端点可用于验证预测器。

仅配置验证:

POST _plugins/_forecast/forecasters/_validate

训练可行性验证:

POST _plugins/_forecast/forecasters/_validate/model

请求正文

请求正文与用于创建预测器的请求正文相同。它必须至少包含以下必填字段:nametime_fieldindicesfeature_attributesforecast_interval

如果配置有效,响应将返回一个空对象 ({})。如果配置无效,响应将包含详细的错误消息。

请求示例:缺少 forecast_interval

以下请求显示了一个省略 forecast_interval 的无效预测器配置

POST _plugins/_forecast/forecasters/_validate
{
  "name": "invalid-forecaster",
  "time_field": "@timestamp",
  "indices": ["network-requests"],
  "feature_attributes": [
    {
      "feature_id": "deny_max",
      "feature_name": "deny max",
      "feature_enabled": true,
      "aggregation_query": {
        "deny_max": {
          "max": {
            "field": "deny"
          }
        }
      }
    }
  ]
}

示例响应

{
  "forecaster": {
    "forecast_interval": {
      "message": "Forecast interval should be set"
    }
  }
}

建议配置

于 3.1 版本引入

根据数据的节奏和密度,为预测器的一个或多个参数(forecast_intervalhorizonhistorywindow_delay)返回适当的值。

端点

POST _plugins/_forecast/forecasters/_suggest/<comma‑separated-types>

types 必须是 forecast_intervalhorizonhistorywindow_delay 中的一个或多个。

请求示例:建议间隔

以下请求分析源数据并根据平均事件频率为预测器建议一个适当的 forecast_interval

POST _plugins/_forecast/forecasters/_suggest/forecast_interval
{
  "name": "interval‑suggest",
  "time_field": "@timestamp",
  "indices": ["network-requests"],
  ...
}

示例响应

{
  "interval": {
    "period": { "interval": 1, "unit": "Minutes" }
  }
}

获取预测器

于 3.1 版本引入

检索预测器及其(可选)最近的任务。

端点

GET _plugins/_forecast/forecasters/<forecaster_id>[?task=(true|false)]

请求示例:包含任务

以下请求返回预测器的元数据,如果指定,还包括其相关任务的详细信息

GET _plugins/_forecast/forecasters/d7-r1YkB_Z-sgDOKo3Z5?task=true

响应包括 forecasterrealtime_taskrun_once_task 部分。


更新预测器

于 3.1 版本引入

更新现有预测器的配置。在进行更新之前,必须停止所有正在运行的预测作业。

任何影响模型的更改,例如修改 category_fieldresult_indexfeature_attributes,都会使 OpenSearch Dashboards UI 中显示的历史结果失效。

端点

PUT _plugins/_forecast/forecasters/<forecaster_id>

请求示例:更新名称、结果索引和类别字段

以下显示了预测器 forecaster-i1nwqooBLXq6T-gGbXI- 的定义

{
    "_index": ".opensearch-forecasters",
    "_id": "forecaster-i1nwqooBLXq6T-gGbXI-",
    "_version": 1,
    "_seq_no": 0,
    "_primary_term": 1,
    "_score": 1.0,
    "_source": {
        "category_field": [
            "service"
        ],
        "description": "ok rate",
        "feature_attributes": [{
            "feature_id": "deny_max",
            "feature_enabled": true,
            "feature_name": "deny max",
            "aggregation_query": {
                "deny_max": {
                    "max": {
                        "field": "deny"
                    }
                }
            }
        }],
        "forecast_interval": {
            "period": {
                "unit": "Minutes",
                "interval": 1
            }
        },
        "schema_version": 2,
        "time_field": "@timestamp",
        "last_update_time": 1695084997949,
        "horizon": 24,
        "indices": [
            "network-requests"
        ],
        "window_delay": {
            "period": {
                "unit": "Seconds",
                "interval": 20
            }
        },
        "transform_decay": 1.0E-4,
        "name": "Second-Test-Forecaster-3",
        "filter_query": {
            "match_all": {
                "boost": 1.0
            }
        },
        "shingle_size": 8,
        "result_index": "opensearch-forecast-result-a"
    }
}

以下请求更新了预测器的 nameresult_indexcategory_field 属性

PUT localhost:9200/_plugins/_forecast/forecasters/forecast-i1nwqooBLXq6T-gGbXI-
{
    "name": "Second-Test-Forecaster-1",
    "description": "ok rate",
    "time_field": "@timestamp",
    "indices": [
        "network-requests"
    ],
    "feature_attributes": [
        {
            "feature_id": "deny_max",
            "feature_name": "deny max",
            "feature_enabled": true,
            "importance": 1,
            "aggregation_query": {
                "deny_max": {
                    "max": {
                        "field": "deny"
                    }
                }
            }
        }
    ],
    "window_delay": {
        "period": {
            "interval": 20,
            "unit": "SECONDS"
        }
    },
    "forecast_interval": {
        "period": {
            "interval": 1,
            "unit": "MINUTES"
        }
    },
    "ui_metadata": {
        "aabb": {
            "ab": "bb"
        }
    },
    "schema_version": 2,
    "horizon": 24,
    "category_field": ["service", "host"]
}


删除预测器

于 3.1 版本引入

删除预测器配置。在删除之前,必须停止所有相关的实时或单次运行的预测作业。如果作业仍在运行,API 将返回 400 错误。

端点

DELETE _plugins/_forecast/forecasters/<forecaster_id>

请求示例:删除预测器

以下请求使用其唯一 ID 删除预测器配置

DELETE _plugins/_forecast/forecasters/forecast-i1nwqooBLXq6T-gGbXI-


启动预测器作业

于 3.1 版本引入

开始预测器的实时预测。

端点

POST _plugins/_forecast/forecasters/<forecaster_id>/_start

请求示例:启动预测器作业

以下请求为指定的预测器启动实时预测

POST _plugins/_forecast/forecasters/4WnXAYoBU2pVBal92lXD/_start

示例响应

{ "_id": "4WnXAYoBU2pVBal92lXD" }

停止预测器作业

于 3.1 版本引入

停止预测器的实时预测。

端点

POST _plugins/_forecast/forecasters/<forecaster_id>/_stop

请求示例:停止预测器作业

以下请求停止指定预测器的实时预测作业

POST _plugins/_forecast/forecasters/4WnXAYoBU2pVBal92lXD/_stop


运行一次分析

于 3.1 版本引入

运行回测(历史)预测。在实时作业处于活动状态时,它无法运行。

端点

POST _plugins/_forecast/forecasters/<forecaster_id>/_run_once

请求示例:运行回测预测

以下请求为指定的预测器启动一次性预测分析

POST _plugins/_forecast/forecasters/<forecaster_id>/_run_once

示例响应

响应返回分配给一次性运行作业的任务 ID

{ "taskId": "vXZG85UBAlM4LplcKI0f" }

请求示例:按任务 ID 搜索预测结果

使用返回的 taskId 查询 opensearch-forecast-results* 索引以获取历史预测输出

GET opensearch-forecast-results*/_search?pretty
{
  "sort": {
    "data_end_time": "desc"
  },
  "size": 10,
  "query": {
    "bool": {
      "filter": [
        { "term": { "task_id": "vXZG85UBAlM4LplcKI0f" } },
        {
          "range": {
            "data_end_time": {
              "format": "epoch_millis",
              "gte": 1742585746033
            }
          }
        }
      ]
    }
  },
  "track_total_hits": true
}

此查询返回与指定任务 ID 匹配的 10 个最新预测结果。


搜索预测器

于 3.1 版本引入

在存储预测器配置的 .opensearch-forecasters 系统索引上提供标准的 _search 功能。您必须直接使用此 API 查询 .opensearch-forecasters,因为该索引是系统索引,无法通过常规的 OpenSearch 查询访问。

端点

GET _plugins/_forecast/forecasters/_search

请求示例:按索引进行通配符搜索

以下请求使用前缀锚定通配符搜索源索引名称以 network 开头的预测器

GET _plugins/_forecast/forecasters/_search
{
  "query": {
    "wildcard": {
      "indices": {
        "value": "network*"
      }
    }
  }
}

network* 匹配 networknetwork-metricsnetwork_2025-06 以及类似的索引名称。

示例响应

{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [{
      "_index": ".opensearch-forecasters",
      "_id": "forecast-i1nwqooBLXq6T-gGbXI-",
      "_version": 1,
      "_seq_no": 0,
      "_primary_term": 1,
      "_score": 1.0,
      "_source": {
        "category_field": ["server"],
        "description": "ok rate",
        "feature_attributes": [{
          "feature_id": "deny_max",
          "feature_enabled": true,
          "feature_name": "deny max",
          "aggregation_query": {
            "deny_max": {
              "max": {
                "field": "deny"
              }
            }
          }
        }],
        "forecast_interval": {
          "period": {
            "unit": "Minutes",
            "interval": 1
          }
        },
        "schema_version": 2,
        "time_field": "@timestamp",
        "last_update_time": 1695084997949,
        "horizon": 24,
        "indices": ["network-requests"],
        "window_delay": {
          "period": {
            "unit": "Seconds",
            "interval": 20
          }
        },
        "transform_decay": 1.0E-4,
        "name": "Second-Test-Forecaster-3",
        "filter_query": {
          "match_all": {
            "boost": 1.0
          }
        },
        "shingle_size": 8
      }
    }]
  }
}

搜索任务

于 3.1 版本引入

查询 .opensearch-forecast-state 索引中的任务。

端点

GET _plugins/_forecast/forecasters/tasks/_search

请求示例:搜索之前的单次运行任务

以下请求检索特定预测器之前的单次运行任务(不包括最近一次),并按 execution_start_time 降序排序

GET _plugins/_forecast/forecasters/tasks/_search
{
  "from": 0,
  "size": 1000,
  "query": {
    "bool": {
      "filter": [
        { "term": { "forecaster_id": { "value": "m5apnooBHh7Wss2wewfW", "boost": 1.0 }}},
        { "term": { "is_latest": { "value": false, "boost": 1.0 }}},
        { "terms": {
            "task_type": [
              "RUN_ONCE_FORECAST_SINGLE_STREAM",
              "RUN_ONCE_FORECAST_HC_FORECASTER"
            ],
            "boost": 1.0
        }}
      ],
      "adjust_pure_negative": true,
      "boost": 1.0
    }
  },
  "sort": [
    { "execution_start_time": { "order": "desc" }}
  ]
}

示例响应

{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": { "value": 1, "relation": "eq" },
    "max_score": null,
    "hits": [
      {
        "_index": ".opensearch-forecast-state",
        "_id": "4JaunooBHh7Wss2wOwcw",
        "_version": 3,
        "_seq_no": 5,
        "_primary_term": 1,
        "_score": null,
        "_source": {
          "last_update_time": 1694879344264,
          "execution_start_time": 1694879333168,
          "forecaster_id": "m5apnooBHh7Wss2wewfW",
          "state": "TEST_COMPLETE",
          "task_type": "RUN_ONCE_FORECAST_SINGLE_STREAM",
          "is_latest": false,
          "forecaster": {
            "description": "ok rate",
            "ui_metadata": { "aabb": { "ab": "bb" }},
            "feature_attributes": [
              {
                "feature_id": "deny_max",
                "feature_enabled": true,
                "feature_name": "deny max",
                "aggregation_query": {
                  "deny_max": {
                    "max": { "field": "deny" }
                  }
                }
              }
            ],
            "forecast_interval": {
              "period": {
                "unit": "Minutes",
                "interval": 1
              }
            },
            "schema_version": 2,
            "time_field": "@timestamp",
            "last_update_time": 1694879022036,
            "horizon": 24,
            "indices": [ "network-requests" ],
            "window_delay": {
              "period": {
                "unit": "Seconds",
                "interval": 20
              }
            },
            "transform_decay": 1.0E-4,
            "name": "Second-Test-Forecaster-5",
            "filter_query": { "match_all": { "boost": 1.0 }},
            "shingle_size": 8
          }
        },
        "sort": [ 1694879333168 ]
      }
    ]
  }
}

热门预测器

于 3.1 版本引入

根据内置或自定义指标,返回给定时间戳范围内的 *top‑k* 实体。

端点

POST _plugins/_forecast/forecasters/<forecaster_id>/results/_topForecasts

查询参数

支持以下查询参数。

名称 类型 必需 描述
split_by 字符串 必需 用于分组的字段(例如 service)。
forecast_from Epoch‑ms 必需 评估窗口中第一个预测的 data_end_time
size 整数 可选 要返回的桶数量。默认为 5
filter_by 枚举 必需 指定是使用内置查询还是自定义查询。必须是 BUILD_IN_QUERYCUSTOM_QUERY
build_in_query 枚举 可选 以下内置排序标准之一是必需的:
MIN_CONFIDENCE_INTERVAL_WIDTH – 按最窄的预测置信区间(最精确)排序。
MAX_CONFIDENCE_INTERVAL_WIDTH – 按最宽的预测置信区间(最不精确)排序。
MIN_VALUE_WITHIN_THE_HORIZON – 按预测窗口内观察到的最低预测值排序。
MAX_VALUE_WITHIN_THE_HORIZON – 按预测窗口内观察到的最高预测值排序。
DISTANCE_TO_THRESHOLD_VALUE – 按预测值与用户定义阈值之间的差值排序。
threshold, relation_to_threshold 混合 条件 仅当 build_in_queryDISTANCE_TO_THRESHOLD_VALUE 时才需要。
filter_query 查询 DSL 可选 filter_by=CUSTOM_QUERY 时使用的自定义查询。
subaggregations 数组 可选 用于计算每个桶内额外指标的嵌套聚合和排序选项列表。

请求示例:针对窄置信区间的内置查询

以下请求返回按最窄置信区间排序的顶部预测实体

POST _plugins/_forecast/forecasters/AG_3t4kBkYqqimCe86bP/results/_topForecasts
{
  "split_by": "service",
  "filter_by": "BUILD_IN_QUERY",
  "build_in_query": "MIN_CONFIDENCE_INTERVAL_WIDTH",
  "forecast_from": 1691008679297
}

示例响应

{
  "buckets": [
    {
      "key": { "service": "service_6" },
      "doc_count": 1,
      "bucket_index": 0,
      "MIN_CONFIDENCE_INTERVAL_WIDTH": 27.655361
    },
    ...
  ]
}

请求示例:置信区间最窄的内置查询

以下请求返回预测值具有最窄置信区间的实体排序列表。结果根据 MIN_CONFIDENCE_INTERVAL_WIDTH 指标按升序排列。

POST _plugins/_forecast/forecasters/AG_3t4kBkYqqimCe86bP/results/_topForecasts
{
  "split_by": "service",
  "filter_by": "BUILD_IN_QUERY",
  "build_in_query": "MIN_CONFIDENCE_INTERVAL_WIDTH",
  "forecast_from": 1691008679297
}

示例响应

{
    "buckets": [
        {
            "key": {
                "service": "service_6"
            },
            "doc_count": 1,
            "bucket_index": 0,
            "MIN_CONFIDENCE_INTERVAL_WIDTH": 27.655361
        },
        {
            "key": {
                "service": "service_4"
            },
            "doc_count": 1,
            "bucket_index": 1,
            "MIN_CONFIDENCE_INTERVAL_WIDTH": 1324.7734
        },
        {
            "key": {
                "service": "service_0"
            },
            "doc_count": 1,
            "bucket_index": 2,
            "MIN_CONFIDENCE_INTERVAL_WIDTH": 2211.0781
        },
        {
            "key": {
                "service": "service_2"
            },
            "doc_count": 1,
            "bucket_index": 3,
            "MIN_CONFIDENCE_INTERVAL_WIDTH": 3372.0469
        },
        {
            "key": {
                "service": "service_3"
            },
            "doc_count": 1,
            "bucket_index": 4,
            "MIN_CONFIDENCE_INTERVAL_WIDTH": 3980.2812
        }
    ]
}

请求示例:阈值以下距离的内置查询

以下请求根据 DISTANCE_TO_THRESHOLD_VALUE 指标返回预测值距离指定阈值最远的顶部实体

POST _plugins/_forecast/AG_3t4kBkYqqimCe86bP/results/_topForecasts
{
  "split_by": "service",                      // group forecasts by the "service" entity field
  "filter_by": "BUILD_IN_QUERY",              // use a built-in ranking metric
  "build_in_query": "DISTANCE_TO_THRESHOLD_VALUE",
  "forecast_from": 1691008679297,             // data_end_time of the first forecast in scope
  "threshold": -82561.8,                      // user-supplied threshold
  "relation_to_threshold": "LESS_THAN"        // keep only forecasts below the threshold
}

示例响应

DISTANCE_TO_THRESHOLD_VALUE 指标计算 forecast_value – threshold。由于 relation_to_thresholdLESS_THAN,API 仅返回负距离并按升序(最负值优先)排序。每个桶包括以下值:

  • doc_count:匹配的预测点数量。
  • DISTANCE_TO_THRESHOLD_VALUE:预测范围内距离阈值最远的值。

以下响应返回 DISTANCE_TO_THRESHOLD_VALUE

{
  "buckets": [
    {
      "key": { "service": "service_5" },
      "doc_count": 18,
      "bucket_index": 0,
      "DISTANCE_TO_THRESHOLD_VALUE": -330387.12
    },
    ...
    {
      "key": { "service": "service_0" },
      "doc_count": 1,
      "bucket_index": 4,
      "DISTANCE_TO_THRESHOLD_VALUE": -83561.8
    }
  ]
}

请求示例:自定义查询和嵌套聚合

以下请求使用自定义查询按名称匹配服务,并按最高预测值对它们进行排名

POST _plugins/_forecast/AG_3t4kBkYqqimCe86bP/results/_topForecasts
{
  "split_by": "service",
  "forecast_from": 1691018993776,
  "filter_by": "CUSTOM_QUERY",
  "filter_query": {
    "nested": {
      "path": "entity",
      "query": {
        "bool": {
          "must": [
            { "term": { "entity.name": "service" } },
            { "wildcard": { "entity.value": "User*" } }
          ]
        }
      }
    }
  },
  "subaggregations": [
    {
      "aggregation_query": {
        "forecast_value_max": {
          "max": { "field": "forecast_value" }
        }
      },
      "order": "DESC"
    }
  ]
}

示例响应

{
  "buckets": [
    {
      "key": { "service": "UserAuthService" },
      "doc_count": 24,
      "bucket_index": 0,
      "forecast_value_max": 269190.38
    },
    ...
  ]
}

概况预测器

于 3.1 版本引入

返回执行时状态,例如初始化进度、每个实体的模型元数据和错误。此 API 对于在运行时检查预测器间隔很有用。

端点

GET _plugins/_forecast/forecasters/<forecaster_id>/_profile[/<type1>,<type2>][?_all=true]

您可以使用 _all 查询参数检索特定的概况类型或请求所有可用类型。

支持以下概况类型:

  • 状态
  • 错误
  • 协调节点
  • 总大小(字节)
  • 初始化进度
  • 模型
  • 总实体数
  • 活跃实体
  • 预测任务

如果您在请求正文中包含 entity 数组,则概况仅限于该实体。

请求示例:带实体过滤器的默认概况

以下请求返回指定实体的默认概况类型(stateerror

GET _plugins/_forecast/forecasters/tLch1okBCBjX5EchixQ8/_profile
{
  "entity": [
    {
      "name": "service",
      "value": "app_1"
    },
    {
      "name": "host",
      "value": "server_2"
    }
  ]
}

示例响应

{
  "state": "RUNNING"
}

请求示例:多种概况类型

以下请求检索 init_progresserrortotal_entitiesstate 概况类型

GET _plugins/_forecast/forecasters/mZ6P0okBTUNS6IWgvpwo/_profile/init_progress,error,total_entities,state

请求示例:所有概况类型

以下请求返回所有可用的概况类型

GET _plugins/_forecast/forecasters/d7-r1YkB_Z-sgDOKo3Z5/_profile?_all=true&pretty


预测器统计

于 3.1 版本引入

返回集群级别或节点级别的统计信息,包括预测器数量、模型计数、请求计数器以及内部预测索引的健康状况。

端点

GET _plugins/_forecast/stats
GET _plugins/_forecast/<node_id>/stats
GET _plugins/_forecast/stats/<stat_name>

请求示例:检索所有统计信息

以下请求检索所有预测器的集群级别统计信息,包括计数、模型信息和索引状态

GET _plugins/_forecast/stats

示例响应

{
  "hc_forecaster_count": 1,
  "forecast_results_index_status": "yellow",
  "forecast_models_checkpoint_index_status": "yellow",
  "single_stream_forecaster_count": 1,
  "forecastn_state_status": "yellow",
  "forecaster_count": 2,
  "job_index_status": "yellow",
  "config_index_status": "yellow",
  "nodes": {
    "8B2S4ClnRFK3GTjO45bwrw": {
      "models": [
        {
          "model_type": "rcf_caster",
          "last_used_time": 1692245336895,
          "model_id": "Doj0AIoBEU5Xd2ccoe_9_entity_SO2kPi_PAMsvThWyE-zYHg",
          "last_checkpoint_time": 1692233157256,
          "entity": [
            { "name": "host_nest.host2", "value": "server_2" }
          ]
        }
      ],
      "forecast_hc_execute_request_count": 204,
      "forecast_model_corruption_count": 0,
      "forecast_execute_failure_count": 0,
      "model_count": 4,
      "forecast_execute_request_count": 409,
      "forecast_hc_execute_failure_count": 0
    }
  }
}

请求示例:检索特定节点的统计信息

以下请求检索特定节点(由节点 ID 标识)的预测器统计信息

GET _plugins/_forecast/8B2S4ClnRFK3GTjO45bwrw/stats

请求示例:检索高基数请求的总数

以下请求检索所有节点的高基数预测器请求总数

GET _plugins/_forecast/stats/forecast_hc_execute_request_count

请求示例:检索特定节点的高基数请求计数

以下请求检索特定节点执行的高基数预测器请求计数

GET _plugins/_forecast/0ZpL8WEYShy-qx7hLJQREQ/stats/forecast_hc_execute_request_count/


预测器信息

于 3.1 版本引入

返回一个整数,表示集群中预测器配置的总数,或检查是否存在满足给定搜索条件的预测器。

端点

GET _plugins/_forecast/forecasters/count
GET _plugins/_forecast/forecasters/match?name=<forecaster_name>

请求示例:计数预测器

以下请求返回当前存储在集群中的预测器配置数量

GET _plugins/_forecast/forecasters/count

示例响应

{
  "count": 2,
  "match": false
}

请求示例:匹配预测器名称

以下请求查找名为 Second-Test-Forecaster-3 的预测器

GET _plugins/_forecast/forecasters/match?name=Second-Test-Forecaster-3

响应示例:匹配成功

{
  "count": 0,
  "match": true
}

响应示例:未找到匹配项

{
  "count": 0,
  "match": false
}
剩余 350 字符

有问题?

想要贡献?