Centos7安装Logstash及基本配置
2017-04-15 20:53
232 查看
安装可以直接用yum安装
配置在/etc/logstash/conf.d
写任何配置文件,任何名都行,比如
vi log_file.conf
然后可以service logstash start了
先说Input:
读取文件基本格式如下:
input
{
file {
path => ["/var/log/*.log", "/var/log/message"]
type => "system"
start_position => "beginning"
}
}
这里实用字段如下:
discover_interval:每隔多久去检查一次被监听的 path 下是否有新文件。默认值是 15 秒。
exclude:不想被监听的文件可以排除出去,这里跟 path 一样支持 glob 展开。
sincedb_path:如果你不想用默认的 $HOME/.sincedb(Windows 平台上在 C:\Windows\System32\config\systemprofile\.sincedb),可以通过这个配置定义 sincedb 文件到其他位置。
sincedb_write_interval:logstash 每隔多久写一次 sincedb 文件,默认是 15 秒。
stat_interval:logstash 每隔多久检查一次被监听文件状态(是否有更新),默认是 1 秒。
start_position:logstash 从什么位置开始读取文件数据,默认是结束位置,也就是说 logstash 进程会以类似 tail -F 的形式运行。如果你是要导入原有数据,把这个设定改成 "beginning",logstash 进程就从头开始读取,有点类似 cat,但是读到最后一行不会终止,而是继续变成 tail -F。
数据处理案例:
filter {
grok {
match => {
"message" => "\s+(?<request_time>\d+(?:\.\d+)?)\s+"
}
}
}
如果用json:
filter {
json {
source => "message"
}
grok {
overwrite => ["@timestamp"]
}
}
Output配置(输出到elasticsearch):
output {
# For detail config for elasticsearch as output,
# See: https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html
elasticsearch {
action => "index" #The operation on ES
hosts => "192.168.6.11:9200" #ElasticSearch host, can be array.
index => "log" #The index to write data to.
}
}
如果想以某个字段为唯一索引,后面有相同数据就更新:
output {
elasticsearch {
hosts => ["192.168.6.11:9200"]
index => "log"
workers => 1
flush_size => 1
idle_flush_time => 1
document_id => "%{od_id}"
doc_as_upsert => true
action => "update"
}
}
具体配置:
http://udn.yyuap.com/doc/logstash-best-practice-cn/index.html
配置在/etc/logstash/conf.d
写任何配置文件,任何名都行,比如
vi log_file.conf
然后可以service logstash start了
先说Input:
读取文件基本格式如下:
input
{
file {
path => ["/var/log/*.log", "/var/log/message"]
type => "system"
start_position => "beginning"
}
}
这里实用字段如下:
discover_interval:每隔多久去检查一次被监听的 path 下是否有新文件。默认值是 15 秒。
exclude:不想被监听的文件可以排除出去,这里跟 path 一样支持 glob 展开。
sincedb_path:如果你不想用默认的 $HOME/.sincedb(Windows 平台上在 C:\Windows\System32\config\systemprofile\.sincedb),可以通过这个配置定义 sincedb 文件到其他位置。
sincedb_write_interval:logstash 每隔多久写一次 sincedb 文件,默认是 15 秒。
stat_interval:logstash 每隔多久检查一次被监听文件状态(是否有更新),默认是 1 秒。
start_position:logstash 从什么位置开始读取文件数据,默认是结束位置,也就是说 logstash 进程会以类似 tail -F 的形式运行。如果你是要导入原有数据,把这个设定改成 "beginning",logstash 进程就从头开始读取,有点类似 cat,但是读到最后一行不会终止,而是继续变成 tail -F。
数据处理案例:
filter {
grok {
match => {
"message" => "\s+(?<request_time>\d+(?:\.\d+)?)\s+"
}
}
}
如果用json:
filter {
json {
source => "message"
}
grok {
overwrite => ["@timestamp"]
}
}
Output配置(输出到elasticsearch):
output {
# For detail config for elasticsearch as output,
# See: https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html
elasticsearch {
action => "index" #The operation on ES
hosts => "192.168.6.11:9200" #ElasticSearch host, can be array.
index => "log" #The index to write data to.
}
}
如果想以某个字段为唯一索引,后面有相同数据就更新:
output {
elasticsearch {
hosts => ["192.168.6.11:9200"]
index => "log"
workers => 1
flush_size => 1
idle_flush_time => 1
document_id => "%{od_id}"
doc_as_upsert => true
action => "update"
}
}
具体配置:
http://udn.yyuap.com/doc/logstash-best-practice-cn/index.html
相关文章推荐
- centos7 + hadoop 1.2.1基本安装配置
- 一次在CentOS7上安装部署Zabbix3.0版本及快速进行基本配置的实例 推荐
- CentOS7 安装Keepalived以及基本配置
- 解决最小化安装Centos7后无法上网的问题,以及安装成功后的基本配置
- Solaris10探营: 安装和基本配置
- AD学习笔记8——活动目录服务的基本安装和配置
- IBM P服务器的Linux基本安装和配置
- Windows 2008 Server Core安装体验手记---基本配置
- Struts的安装与基本配置
- Qt第一天——安装与基本配置
- nagios全攻略(二)----基本安装和配置(下)
- 关于Documentum的安装和系统基本配置
- Solaris10从下载、安装到基本配置过程
- Debian 基本系统安装和配置
- nagios全攻略(二)----基本安装和配置(上)
- Win2000活动目录服务的基本安装和配置
- Mysql快速安装与基本配置
- jspwiki v2.1.86基本安装和配置
- nagios全攻略(二)----基本安装和配置(下) 推荐
- SVN基本安装、配置!