Logstash API

edit

以下API用于管理由Logstash 集中管理使用的管道:

创建或更新 Logstash 管道 API

edit

此API用于创建或更新用于Logstash集中管理的Logstash管道。

请求

edit

PUT _logstash/pipeline/

先决条件

edit
  • 如果启用了Elasticsearch安全功能,您必须拥有manage_logstash_pipelines集群权限才能使用此API。

描述

edit

创建一个Logstash管道。如果指定的管道存在,则替换该管道。

路径参数

edit
<pipeline_id>
(必需,字符串)管道的标识符。

请求体

edit
description
(可选, 字符串) 管道的描述。此描述不会被Elasticsearch或Logstash使用。
last_modified
(必需,字符串) 管道最后一次更新的日期。必须采用yyyy-MM-dd'T'HH:mm:ss.SSSZZ strict_date_time格式。
pipeline
(必需,字符串) 管道的配置。有关支持的语法,请参阅 Logstash 配置文档
pipeline_metadata
(必需, 对象) 关于管道的可选元数据。可以包含任何内容。此元数据不会由 Elasticsearch 或 Logstash 生成或使用。
pipeline_settings
(Required, object) Settings for the pipeline. Supports only flat keys in dot notation. For supported settings, see the Logstash settings documentation.
username
(必需,字符串) 最后更新管道的用户。

示例

edit

以下示例创建一个名为 my_pipeline 的新管道:

PUT _logstash/pipeline/my_pipeline
{
  "description": "Sample pipeline for illustration purposes",
  "last_modified": "2021-01-02T02:50:51.250Z",
  "pipeline_metadata": {
    "type": "logstash_pipeline",
    "version": "1"
  },
  "username": "elastic",
  "pipeline": "input {}\n filter { grok {} }\n output {}",
  "pipeline_settings": {
    "pipeline.workers": 1,
    "pipeline.batch.size": 125,
    "pipeline.batch.delay": 50,
    "queue.type": "memory",
    "queue.max_bytes": "1gb",
    "queue.checkpoint.writes": 1024
  }
}

如果请求成功,您将收到一个带有适当状态码的空响应。

删除 Logstash 管道 API

edit

此 API 删除用于 Logstash 集中管理的管道。

请求

edit

DELETE _logstash/pipeline/

先决条件

edit
  • 如果启用了Elasticsearch安全功能,您必须拥有manage_logstash_pipelines集群权限才能使用此API。

描述

edit

删除一个 Logstash 管道。

路径参数

edit
<pipeline_id>
(必需,字符串) 管道的标识符。

示例

edit

以下示例删除了名为 my_pipeline 的管道:

DELETE _logstash/pipeline/my_pipeline

如果请求成功,您将收到一个带有适当状态码的空响应。

获取管道 API

edit

此API用于检索用于 Logstash集中管理的管道。

请求

edit

GET _logstash/pipeline

GET _logstash/pipeline/

先决条件

edit
  • If the Elasticsearch security features are enabled, you must have the manage_logstash_pipelines cluster privilege to use this API.

描述

edit

检索一个或多个 Logstash 管道。

路径参数

edit
<pipeline_id>
(可选,字符串) 以逗号分隔的管道标识符列表。

示例

edit

以下示例检索名为 my_pipeline 的管道:

GET _logstash/pipeline/my_pipeline

如果请求成功,响应的主体包含管道定义:

{
  "my_pipeline": {
    "description": "Sample pipeline for illustration purposes",
    "last_modified": "2021-01-02T02:50:51.250Z",
    "pipeline_metadata": {
      "type": "logstash_pipeline",
      "version": "1"
    },
    "username": "elastic",
    "pipeline": "input {}\n filter { grok {} }\n output {}",
    "pipeline_settings": {
      "pipeline.workers": 1,
      "pipeline.batch.size": 125,
      "pipeline.batch.delay": 50,
      "queue.type": "memory",
      "queue.max_bytes": "1gb",
      "queue.checkpoint.writes": 1024
    }
  }
}