处理管道故障

处理管道故障 #

每个摄取管道由一系列按顺序应用于文档的处理程序组成。如果处理程序失败,整个管道将失败。您有两种处理故障的选项:

  • Fail the entire pipeline:使整个管道失败。如果处理程序失败,整个管道将失败,文档将不会被索引。
  • Fail the current processor and continue with the next processor:使当前处理程序失败并继续下一个处理程序。如果您想在某个处理程序失败的情况下继续处理文档,这可能会很有用。

默认情况下,如果管道中的某个处理器失败,则摄取管道会停止。如果您希望在处理器失败时继续运行管道,您可以在创建管道时将该处理器的 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 配置为空,Easysearch 也会运行管道中的其他处理器:

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"
            }
          }
        ]
      }
    }
  ]
}

如果处理器失败,Easysearch 会记录失败并继续运行搜索管道中剩余的所有处理器。要检查是否有任何失败,您可以使用摄取管道指标。

摄取管道的监控指标 #

要查看摄取管道的监控指标,请使用节点统计 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
                  }
                }
              }
            ]
          }
        }
      }
    }
  }
}

故障排除:处理摄取管道失败:您首先应该检查日志,看是否有任何错误或警告可以帮助您确定失败的原因。Easysearch 日志包含有关失败的摄取管道的信息,包括失败的处理器和失败的原因。