创建或更新 Logstash 管道 API

编辑

创建或更新 Logstash 管道 API

编辑

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

请求

编辑

PUT _logstash/pipeline/<pipeline_id>

先决条件

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

描述

编辑

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

路径参数

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

请求正文

编辑
description
(可选,字符串) 管道的描述。此描述不被 Elasticsearch 或 Logstash 使用。
last_modified
(必需,字符串) 管道上次更新的日期。必须采用 yyyy-MM-dd'T'HH:mm:ss.SSSZZ strict_date_time 格式。
pipeline
(必需,字符串) 管道的配置。有关支持的语法,请参阅 Logstash 配置文档
pipeline_metadata
(必需,对象) 关于管道的可选元数据。可以包含任何内容。此元数据不被 Elasticsearch 或 Logstash 生成或使用。
pipeline_settings
(必需,对象) 管道的设置。仅支持点表示法中的扁平键。有关支持的设置,请参阅 Logstash 设置文档
username
(必需,字符串) 上次更新管道的用户。

示例

编辑

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

resp = client.logstash.put_pipeline(
    id="my_pipeline",
    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
        }
    },
)
print(resp)
response = client.logstash.put_pipeline(
  id: 'my_pipeline',
  body: {
    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
    }
  }
)
puts response
const response = await client.logstash.putPipeline({
  id: "my_pipeline",
  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,
    },
  },
});
console.log(response);
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
  }
}

如果请求成功,您将收到一个空响应,其中包含相应的状态代码。