设为首页 加入收藏

TOP

Logstash 入门实战(5)--output plugin 介绍
2023-07-25 21:31:10 】 浏览:36
Tags:Logstash --output plugin 介绍

本文主要介绍 Logstash 的一些常用输出插件;相关的环境及软件信息如下:CentOS 7.9、Logstash 8.2.2。

1、Stdout 输出插件

Stdout 插件把结果数据输出到标准输出。

input {
  stdin {
  }
}

output {
  stdout {
  }
}

2、File 输出插件

File 插件把结果数据输出文件。

input {
  stdin {
  }
}

output {
  file {
    path => "/home/hadoop/a.txt"
    codec => line {
      format => "%{message}" #只把原始数据写入文件
    }
  }
}

3、Elasticsearch 输出插件

Elasticsearch 插件把结果数据写入到 Elasticsearch 中。

input {
  stdin {
    codec => json
  }
}

output {
  stdout { } #同时把结果输出到控制台
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "my-index"
    user => "elastic"
    password => "123456"
  }
}

4、Kafka 输出插件

Kafka 插件把结果数据写入到 Kafka 中。

input {
  stdin {
  }
}

output {
  stdout {}
  kafka {
    topic_id => "test"
    codec => "plain"
  }
}

5、Rabbitmq 输出插件

Rabbitmq 插件把结果数据写入到 Rabbitmq 中。

input {
  stdin {
  }
}

output {
  stdout {} #同时把结果输出到控制台
  rabbitmq {
    host => "localhost"
    port => 5672
    user => "admin"
    password => "admin"
    exchange => "" #默认交换机
    exchange_type => "direct"
    key => "test" #exchance绑定queue的routeKey
    codec => "plain"
  }
}

6、Http 输出插件

Rabbitmq 插件使用结果数据调用配置的 HTTP 接口。

input {
  stdin {
  }
}

output {
  stdout {}
  http {
    url => "http://localhost:8080/test/hello2"
    http_method => "post"
    format => "json"
    codec => "json"
  }
}

7、Redis 输出插件

Redis 插件把结果数据写入到 Redis 中。

input {
  stdin {
  }
}

output {
  stdout {
  }
  redis {
    host => "localhost"
    port => 6379
    data_type => "list"
    key => "a"
    codec => plain {
      format => "%{message}" #只把原始数据写入文件
    }
  }
}

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Java 日志框架学习笔记 下一篇Statement对象与PreparedStatemen..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目