Logstash:多个配置文件(conf)

对于多个配置的处理方法,有多个处理方法:

  • 多个pipeline
  • 一个pipleline处理多个配置文件

一个pipeline含有一个逻辑的数据流,它从input接收数据,并把它们传入到队列里,经过worker的处理,最后输出到output。这个output可以是Elasticsearch或其它。下面针对这两种情况,来分别进行描述。

多个pipeline

cat apache.conf

    input {
file {
path => "/Users/liuxg/data/multi-input/apache.log"
start_position => "beginning"
sincedb_path => "/dev/null"
# ignore_older => 100000
type => "apache"
}
} filter {
grok {
match => {
"message" => '%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response:int} (?:-|%{NUMBER:bytes:int}) %{QS:referrer} %{QS:agent}'
}
}
} output {
stdout {
codec => rubydebug
} elasticsearch {
index => "apache_log"
template => "/Users/liuxg/data/apache_template.json"
template_name => "apache_elastic_example"
template_overwrite => true
}
}
# cat daily.conf

    input {
file {
path => "/Users/liuxg/data/multi-pipeline/apache-daily-access.log"
start_position => "beginning"
sincedb_path => "/dev/null"
type => "daily"
}
} filter {
grok {
match => {
"message" => '%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response:int} (?:-|%{NUMBER:bytes:int}) %{QS:referrer} %{QS:agent}'
}
}
} output {
stdout {
codec => rubydebug
} elasticsearch {
index => "apache_daily"
template => "/Users/liuxg/data/apache_template.json"
template_name => "apache_elastic_example"
template_overwrite => true
}
}

接下来,修改pipelines.yml文件。在logstash的安装目录下的config文件目录下,修改pipelines.yml文件。

- pipeline.id: daily
pipeline.workers: 1
pipeline.batch.size: 1
path.config: "/Users/liuxg/data/multi-pipeline/daily.conf"
- pipeline.id: apache
queue.type: persisted
path.config: "/Users/liuxg/data/multi-pipeline/apache.conf"

在上面的配置中,把daily.conf和apache.conf分别置于两个不同的pipleline中。

这样操作配置已经完成了。进入到longstash的安装目录。我们通过如下的命令来运行:

./bin/logstash

在terminal中,可以看到有两个piple在同时运行,也可以在Kibana中看到我们的index结果。

一个pipeline

同样可以修改位于Logstash安装目录下的config子目录里的pipleline.yml文件,并把它修改为:

- pipeline.id: my_logs
queue.type: persisted
path.config: "/Users/liuxg/data/multi-pipeline/*.conf"

把所有位于/Users/liuxg/data/multi-pipeline/下的所有的conf文件都放于一个pipeline里。

按照上面同样的方法来运行我们的应用:

./bin/logstash

从运行的结果中看到了两个同样的输出。这是为什么呢?这是因为我们把两个.conf文件放于一个pipleline里运行,那么我们有两个stdout的输出分别位于两个.conf文件了。

在Kibana里可以看到我们的最终的index数据:

我们可以看到在apache_log里有20条数据,它包括两个log文件里所有的事件,这是因为它们都是一个pipleline。同样我们可以在apache_daily看到同样的20条数据。

最新文章

  1. Cordova学习(一) 环境搭建
  2. C#.Net 图片处理大全
  3. eclipse 中卸载插件的方法
  4. 超轻量级spring模板方案
  5. S2 结业考试前改错汇总
  6. ORACLE的RMAN
  7. iOS之使用QLPreviewController打开文件,处理txt文件出现乱码的情况
  8. logstash date插件介绍
  9. Centos 7 安装Mono和Jexus 默认目录安装 (一)
  10. 基于visual Studio2013解决面试题之0502字符串左移
  11. python爬虫第一天
  12. Advice详解
  13. SSE推送数据
  14. java框架之Spring(2)-注解配置IOC&AOP配置
  15. 集合总结一(ArrayList的实现原理)
  16. EasyUI学习总结(三)——easyloader源码分析(转载)
  17. 《Effective C++》 目录:
  18. Stochastic Optimization Techniques
  19. C#高级编程9-第2章 核心C#
  20. Google POI下载工具破解之路

热门文章

  1. serf 中去中心化系统的原理和实现
  2. Winform中在使用Dock属性设计页面布局控件的顺序导致页面效果不同的问题
  3. 反射实体类拼接SQL语句
  4. CountDownLatch(闭锁)、Semaphore(信号量)、CyclicBarrier
  5. 这可能最简单的一种PS图片特效,零基础小白教程
  6. springmvc学习笔记三:整合JDBC,简单案例==数据库事务配置(切面)
  7. iOS开发时获取第一响应者
  8. 企业账号发布APP
  9. 彻底解决Python3写爬虫或网站时的乱码问题
  10. 用Toad for Oracle创建数据库表空间和用户