处理管道故障
1.0 版引入
每个摄入管道都由一系列按顺序应用于文档的处理器组成。如果某个处理器失败,整个管道将失败。您有两种处理故障的选项:
- 使整个管道失败:如果处理器失败,则整个管道将失败,并且文档将不会被索引。
- 使当前处理器失败并继续下一个处理器:如果您希望即使某个处理器失败也能继续处理文档,此选项会很有用。
默认情况下,如果摄入管道中的某个处理器失败,管道将停止。如果您希望在处理器失败时管道继续运行,可以在创建管道时将该处理器的 ignore_failure
参数设置为 true
PUT _ingest/pipeline/my-pipeline/
{
"description": "Rename 'provider' field to 'cloud.provider'",
"processors": [
{
"rename": {
"field": "provider",
"target_field": "cloud.provider",
"ignore_failure": true
}
}
]
}
您可以指定 on_failure
参数,使其在处理器失败后立即运行。如果您已指定 on_failure
,即使 on_failure
配置为空,OpenSearch 也会继续运行管道中的其他处理器。
PUT _ingest/pipeline/my-pipeline/
{
"description": "Add timestamp to the document",
"processors": [
{
"date": {
"field": "timestamp_field",
"formats": ["yyyy-MM-dd HH:mm:ss"],
"target_field": "@timestamp",
"on_failure": [
{
"set": {
"field": "ingest_error",
"value": "failed"
}
}
]
}
}
]
}
如果处理器失败,OpenSearch 会记录故障并继续运行搜索管道中所有剩余的处理器。要检查是否存在任何故障,您可以使用摄入管道指标。
摄入管道指标
要查看摄入管道指标,请使用 节点统计 API
GET /_nodes/stats/ingest?filter_path=nodes.*.ingest
响应包含所有摄入管道的统计信息,例如
{
"nodes": {
"iFPgpdjPQ-uzTdyPLwQVnQ": {
"ingest": {
"total": {
"count": 28,
"time_in_millis": 82,
"current": 0,
"failed": 9
},
"pipelines": {
"user-behavior": {
"count": 5,
"time_in_millis": 0,
"current": 0,
"failed": 0,
"processors": [
{
"append": {
"type": "append",
"stats": {
"count": 5,
"time_in_millis": 0,
"current": 0,
"failed": 0
}
}
}
]
},
"remove_ip": {
"count": 5,
"time_in_millis": 9,
"current": 0,
"failed": 2,
"processors": [
{
"remove": {
"type": "remove",
"stats": {
"count": 5,
"time_in_millis": 8,
"current": 0,
"failed": 2
}
}
}
]
}
}
}
}
}
}
排查摄入管道故障:您首先应该做的是检查日志,查看是否有任何错误或警告可以帮助您确定故障原因。OpenSearch 日志包含有关失败的摄入管道的信息,包括失败的处理器和失败原因。