redis日志mysql_ELK+redis管理mysql-slow和nginx的access日志

d9e8d45e335aa797e26d3de7f5e3ccc2.png

客户端logstash把日志提交到服务端的redis里面,服务端logstash在从服务端的redis提取日志到ela中

1:客户端配置如下

input {

file {

path => "/data/nginx/nginx/logs/nginx_logstash.log"

type => "nginx_access"

start_position => "beginning"

codec => "json"

}

file {

path => "/data/mysql_db/db_inst1/slow.log"

type => "slow-mysql"        #指定日志类型,以便在一个配置文件中收集多个日志,用来区别输出

start_position => "beginning"

codec =>  multiline {

pattern => "^# User@Host"

negate => true

what => "previous"

}

}

}

output {

if [type] == "nginx_access" {

redis {

host => "192.168.0.147"

key => "nginx_access"

data_type => "list"

port => "6379"

# type => "redis_nginx-input"

}

}

if [type] == "slow-mysql" {

redis {

host => "192.168.0.147"

key => "slow-mysql"

data_type => "list"

port => "6379"

#type => "redis_slow-input"

}

}

}

服务端配置如下:

input {

redis {

host => "192.168.0.147"

port => "6379"

key => "nginx_access"

type => "nginx_access"

data_type => "list"

}

redis {

type => "slow-mysql"

host => "192.168.0.147"

data_type => "list"

key => "slow-mysql"

port => "6379"

}

}

output {

if [type] == "nginx_access" {

elasticsearch {

host => ["192.168.0.147:9200","192.168.0.148:9200"]

protocol => "http"

index => "nginx-access-%{+YYYY.MM}"

}

}

if [type] == "slow-mysql" {

elasticsearch {

host => ["192.168.0.147:9200","192.168.0.148:9200"]

protocol => "http"

index => "slow-mysql-%{+YYYY.MM}"

}

}

}

在启动相应的服务:

客户端:/opt/logstash/bin/logstash -f ./nginx-access_mysql-slow.conf

服务端:/opt/logstash/bin/logstash -f ./logstash_redis-ela.conf

在登陆192.168.0.147:/_plugin/head   查看数据

1c8f3e21a8cc63cd6a9015ed3fe3f6ed.png

发现数据已经到elasticsearch里面

在登录到kibana中设置索引到各个日志文件

1:

773bbf7c03380c6259fe4ca2b8f8ff77.png

2:

8cb6add59869748c34cfc6126f0efb7b.png

3:查看日志生成

9b6afebe8b478ca16c01b716f44053cc.png

阅读(681) | 评论(0) | 转发(0) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值