ELK下logstash通过redis收集日志_logstash -f etc logstash conf

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以戳这里获取

#vim /etc/redis.conf
bind 0.0.0.0
daemonize yes
save “”
requirepass 123456


**3.启动redis**  
 systemctl enable redis  
 systemctl restart redis


## (2)配置logstash将日志写入到redis中


**1丶修改配置文件**



input {
file {
path => “/var/log/messages”
type => “systemlog”
start_position => “beginning”
stat_interval => “2”
}
}

output {
if [type] == “systemlog” {
redis {
data_type => “list”
host => “192.168.1.31”
db => “6”
port => “6379”
password => “123456”
key => “systemlog”
}
}
}


**2丶启动**



logstash -f /etc/logstash/conf.d/redis.conf -t
logstash -f /etc/logstash/conf.d/redis.conf


**3丶写入日志到messages日志中**



cat /etc/hosts >>/var/log/messages


**4丶登录redis查看**



redis-cli -h 192.168.1.31

192.168.1.31:6379> auth 123456
OK
192.168.1.31:6379> select 6
OK
192.168.1.31:6379[6]> keys *

  1. “systemlog”
    192.168.1.31:6379[6]> llen systemlog
    (integer) 11292
    192.168.1.31:6379[6]> lpop systemlog

## (3)配置logstash从redis中取出数据到elasticsearch


**1丶修改配置文件**



input {
redis {
type => “systemlog”
host => “192.168.1.31”
password => ‘123456’
port => “6379”
db => “6”
data_type => “list”
key => “systemlog”
}
}
output {
if [type] == “systemlog” {
elasticsearch {
hosts => [“192.168.1.31:9200”]
index => “redis-systemlog-%{+YYYY.MM.dd}”
}
}
}




![img](https://img-blog.csdnimg.cn/img_convert/3a9557cbe9aaa05ce30644031bd5a1e9.png)
![img](https://img-blog.csdnimg.cn/img_convert/8e5ed263fff98ac16f50a682ae66302c.png)
![img](https://img-blog.csdnimg.cn/img_convert/1c5ee0d33ffdba4b25073adb4d04b54f.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!**

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化的资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618631832)**

比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化的资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618631832)**

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值