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条数据。

Logstash:多个配置文件(conf)的更多相关文章

  1. logstash 对配置文件conf敏感信息,密码等加密

    logstash的配置文件conf经常会涉及敏感信息,比如ES,mysql的账户密码等,以下使用logstash导入mysql为例子,加密隐藏mysql的密码. 在向keystore中添加key及其s ...

  2. ELK - logstash 多个配置文件及模板的使用

    目录 - 前言 - 多配置文件的实现方式 - 为logstash 增加模板 - 将 logstash 作为服务启动 1. 前言 在使用 logstash 编写多个配置文件,写入到 elasticsea ...

  3. 增加nginx虚拟主机配置文件(conf.d)

    有时候我们按照了nginx后发现配置文件只有一个,/etc/nginx/nginx.conf 所有的配置包括虚拟目录也在此文件中配置, 这样当虚拟主机多了管理就有些不方便了, 这是需要我们把配置文件拆 ...

  4. nginx 分离配置文件 conf.d和default.conf

    1. 在 nginx.conf 文件中引用 conf.d 下的所有配置文件 #在http配置节的末尾添加配置引用 http { ... #gzip on; include /etc/nginx/con ...

  5. 解决clover配置文件conf.plist中nv_disable=1或者nvda_drv=1不生效或者说不能删除的问题

    情况一:U盘安装MacOS的时候conf.plist中设置了nv_disable=1,但是启动的时候任然显示nvda_drv=1. 这种情况一般出现在该机器曾经安装过MacOS,MacOS会将这个参数 ...

  6. redis配置文件.conf和常用配置

    1,配置文件在哪 2,Units单位 1 配置大小单位,开头定义了一些基本的度量单位,只支持bytes,不支持bit 2 对大小写不敏感 3,INCLUDES包含 和我们的spring配置文件类似,可 ...

  7. mongodb配置文件.conf

    启动方式 ./bin/mongod -f MongoDB.conf 会看到 about to fork child process, waiting until server is ready for ...

  8. 数据库配置文件 conf.properties

    #数据库配置 #mysql hibernate.dialect =org.hibernate.dialect.MySQLDialect jdbc.driverClassName =com.mysql. ...

  9. zookeeper 配置文件conf目录下 zoo文件 配置详解

    clientPort:客户端尝试连接server的端口号 (对外服务端口) 通常为2181 dataDir:存放快照文件snapshot的目录.(储存数据的目录) dataLogDir:事务日志存放位 ...

  10. logstash报错401 需要在logstash启动的配置文件中增加es的用户名和密码

随机推荐

  1. 2018-2-13-win10-uwp-切换主题

    原文:2018-2-13-win10-uwp-切换主题 title author date CreateTime categories win10 uwp 切换主题 lindexi 2018-2-13 ...

  2. .net post请求wcf

    class Program { static void Main(string[] args) { }); var r = HttpHelper.PostRequest("http://lo ...

  3. 机器学习实战:基于Scikit-Learn和TensorFlow 读书笔记 第6章 决策树

    数据挖掘作业,要实现决策树,现记录学习过程 win10系统,Python 3.7.0 构建一个决策树,在鸢尾花数据集上训练一个DecisionTreeClassifier: from sklearn. ...

  4. Winform中自定义ZedGraph右键复制成功后的提示

    场景 Winform中实现ZedGraph中曲线右键显示为中文: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100115292 ...

  5. 环信即时通讯在工程中的安装——Nusen_Liu

    即时通讯-环信 准备 1.下载SDK http://www.easemob.com/download 2.证书下载上传 后期发送消息 需要推送发送的内容 http://docs.easemob.com ...

  6. Android Studio当中的创建新方法的快捷键该如何使用?

    当有红线出现的时候,我们的代码并没有编译出错,则需要输入alt+enter则可以得到相应的神奇效果了.这个方法我竟然今天才知道,也真是丢脸了.比如说我们书写了一个新的没有创建的方法,我们直接输入alt ...

  7. Linux:目录的查找

    搜索文件与目录 find [查找范围] [查找条件表达式] 常用的选项 -name 按名称查找,允许使用通配符 -type 按文件类型查找 文件类型包括: 普通文件 f 目录 d 块设备文件 b 字符 ...

  8. C学习笔记(9)--- 预处理器,头文件

    1.预处理器: 预处理器不是编译器的组成部分,但是它是编译过程中一个单独的步骤.简言之,C 预处理器只不过是一个文本替换工具而已,它们会指示编译器在实际编译之前完成所需的预处理. 我们将把 C 预处理 ...

  9. SpringBoot Junit Demo

    package com.yunen.camera.test; import org.junit.Before; import org.junit.Test; import org.junit.runn ...

  10. MySQL学习笔记3——DCL

    DCL(数据控制语言) 1.创建用户 *CREATE USER 用户名@IP地址 IDENTIFIED BY '密码'; >用户只能在指定的IP地址上登录*CREATE USER 用户名@'%' ...