标签:
操作系统:Cent OS 7
Logstash版本:2.1.1.tar.gz
JDK版本:1.7.0_51
SSH Secure Shell版本:XShell 5
下载:curl -O https://download.elasticsearch.org/logstash/logstash/logstash-2.1.1.tar.gz
解压:tar zxvf logstash-2.1.1.tar.gz
在终端中,像下面这样运行命令来启动 Logstash 进程:
进入logstash的bin目录 cd logstash-2.1.1/bin
执行命令 ./logstash -e ‘input{stdin{}}output{stdout{codec=>rubydebug}}‘
然后你会发现终端在等待你的输入。没问题,敲入 Hello World,回车,然后看看会返回什么结果!
./logstash -e ‘input{stdin{}}output{stdout{codec=>rubydebug}}‘
hello world
{
"message" => "hello world",
"@version" => "1",
"@timestamp" => "2015-11-30T09:07:18.529Z",
"host" => "atman081.atmandomain"
}
没错!你搞定了!这就是全部你要做的。
定义一个stdout_kafka.conf文件,配置内容为
input { file { path => ["/var/log/diagonAlley/diagonAlley.log"] type => "log4j" start_position => "beginning" } } output { kafka { bootstrap_servers => "192.168.1.181:9092,192.168.1.181:9093,192.168.1.181:9094" topic_id => "logstash" compression_type => "gzip" } }
将stdout_kafka.conf文件放至bin目录
运行如下命令,并查看控制台输出
./logstash -f stdout_kafka.conf &
定义一个stdout_elasticsearch.conf文件,配置内容为
input { kafka { zk_connect => "192.168.1.181:2181" topic_id => "logstash" } } output { elasticsearch { hosts => ["192.168.1.181:9100"] index => "logstash-%{type}-%{+YYYY.MM.dd}" workers => 5 } }
将stdout_elasticsearch.conf文件放至bin目录
运行如下命令,并查看控制台输出
./logstash -f stdout_elasticsearch.conf &
标签:
原文地址:http://www.cnblogs.com/wangyangliuping/p/5546579.html