logstash配置多入多出并互相隔离

需求:需要利用同一logstash进程采集不同日志,输出到es的不同index,各输入输出隔离;

主要需要解决如下两个问题:

1、如何加载多个配置文件?

普通启动方式:nohup bin/logstash -f config/logstash.conf &

 

多配置文件启动方式:nohup bin/logstash -f config/java-conf &

注意:java-conf为目录,将加载该目录下所有配置文件;不要使用config/java-conf/*.conf

问题:配置不当,各输入输出会存在交叉,解决办法参考以下第二点。

2、如何隔离各输入输出?

利用type,对输入输出进行筛选,配置参考:

log1.conf
input {
  file {
    type => "log1" 
    path => "/**/log1.log" 
    discover_interval => 10 # 监听间隔 
    start_position => "beginning" #从头开始
  }
}

#输出到elasticsearch 
output {
  if [type] == "log1"{
    elasticsearch {
    index => "log1-%{+YYYY.MM.dd}" 
    hosts => "192.168.2.32:9200"   #输出到elasticsearch 对应服务器
    }
  }
}

log2.conf
input {
  file {
    type => "log2" 
    path => "/**/log2.log" 
    discover_interval => 10 # 监听间隔 
    start_position => "beginning" #从头开始
  }
}

#输出到elasticsearch 
output {
  if [type] == "log2"{
    elasticsearch {
    index => "log2-%{+YYYY.MM.dd}" 
    hosts => "192.168.2.32:9200"   #输出到elasticsearch 对应服务器
    }
  }
}

PS:index名不能包含大写字母。

 


 

启动多个logstash并行消费kafka数据。

1.设置相同topic

2.设置相同groupid

3.设置不同clientid

4.input 的这个参数 consumer_threads => 10 多实列相加最好等于 topic分区数

如果一个logstash得参数大于topic,则topic数据都会被这个logstash消费掉

logstash_1

 

 

logstash_2

 


---------------------
作者:林沂梵
来源:CSDN
原文:https://blog.csdn.net/jyb199158/article/details/82841731
版权声明:本文为博主原创文章,转载请附上博文链接!

posted @   Bigben  阅读(4510)  评论(1编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示