天天看点

ELK收集日志

1.如果内存紧张的话可以把logstash(收集日志)做到另外一台主机上

2.先开两台主机

ELK收集日志

3.在133上面解压包,把下面的解压了

ELK收集日志

4.修改es配置文件 vim /etc/elasticsearch/elasticsearch.yml

ELK收集日志
ELK收集日志
ELK收集日志
ELK收集日志
ELK收集日志
ELK收集日志

5.修改kibana配置文件 vim /etc/kibana/kibana.yml

ELK收集日志
ELK收集日志
ELK收集日志

6.想在哪个上面收集日志就在那个上面安装logstash 我这里把他安装到134上

7.vim /etc/logstash/conf.d/messages.conf

【1】

我这个是监控两个 分别是系统日志和apache

input {
   file {
       path => "/var/log/messages"                要监控日志的绝对路径
       type => "system-log"                       自己定义的名字
       start_position => "beginning"             
 }
   file {
       path => "/var/log/httpd/*_log"            
       type => "httpd-log"
       start_position => "beginning"
 }
}
output {
   if [type] == "system-log" {
       elasticsearch {
       hosts => "192.168.242.133:9200"                 把上面收集的日志信息发送到133主机上的es上
       index => "systemc-log_%{+YYYY.MM.dd}"           给上面的名字加个日期
 }
}
   if [type] == "httpd-log" {
       elasticsearch {
       hosts => "192.168.242.133:9200"
       index => "httpd-log_%{+YYYY.MM.dd}"
 }
}
}

           

重启logstash systemctl restart logstash

出现9600 就可以

ELK收集日志

8.查看添加索引

ELK收集日志

继续阅读