本文主要介绍 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}" #只把原始数据写入文件
    }
  }
}

 

原文地址:http://www.cnblogs.com/wuyongyin/p/16741881.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性