前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ELK的上线之路(五):—— Logstash进阶解耦

ELK的上线之路(五):—— Logstash进阶解耦

原创
作者头像
江小白
修改2018-07-03 17:58:31
6600
修改2018-07-03 17:58:31
举报

利用redis来实现logstash的解耦:

安装redis,直接采用yum安装:

vi /etc/redis.conf (简单的编辑配置)

daemonize yes(后台运行)

bind 192.168.12.74 (修改监听的地址)

启动redis:

systemctl start redis

redis-cli -h 192.168.12.74(访问测试)

编辑logstash的配置文件:

编辑:redis-out.conf(输出到redis)
编辑:redis-out.conf(输出到redis)
启动logstash,标准输入测试。
启动logstash,标准输入测试。
info查看信息,并查看相关内容。
info查看信息,并查看相关内容。
启动logstash,标准输出到elasticsearch。
启动logstash,标准输出到elasticsearch。

生产配置文件,输入redis:

input {

file {

path => "/var/log/messages"

type => "system"

start_position => "beginning"

}

syslog {

type => "system-syslog"

host => "192.168.12.74"

port => "514"

}

file {

path => "/var/log/ucdisk/ucdisk-error.log"

type => "ucdisk-error"

start_position => "beginning"

codec => multiline {

pattern => "^[0-9]"

negate => true

what => "previous"

}

}

file {

path => "/var/log/nginx/access.log_json"

codec => "json"

type => "nginx-log"

start_position => "beginning"

}

}

output {

if [type] == "system" {

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "system"

}

}

if [type] == "ucdisk-error" {

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "ucdisk-error"

}

}

if [type] == "nginx-log" {

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "nginx-log"

}

}

if [type] == "system-syslog" {

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "system-syslog"

}

}

}

生产配置文件,redis读出:

input {

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "system"

type => "system"

}

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "ucdisk-error"

type => "ucdisk-error"

}

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "nginx-log"

type => "nginx-log"

}

redis {

host => "192.168.12.74"

port => "6379"

db => "6"

data_type => "list"

key => "system-syslog"

type => "system-syslog"

}

}

output {

if [type] == "system" {

elasticsearch {

hosts => [ "192.168.12.74:9200"]

index => "system-%{+YYYY.MM.dd}"

}

}

if [type] == "ucdisk-error" {

elasticsearch {

hosts => [ "192.168.12.74:9200"]

index => "ucdisk-error-%{+YYYY.MM.dd}"

}

}

if [type] == "nginx-log" {

elasticsearch {

hosts => [ "192.168.12.74:9200"]

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

}

}

if [type] == "system-syslog" {

elasticsearch {

hosts => [ "192.168.12.74:9200"]

index => "system-syslog-%{+YYYY.MM.dd}"

}

}

}

启动logstash:

[root@elk-node1 conf]# /usr/local/logstash/bin/logstash -f /usr/local/logstash/conf/redis.conf

Settings: Default filter workers: 2

Logstash startup completed

[root@elk-node2 conf]# /usr/local/logstash/bin/logstash -f /usr/local/logstash/conf/redis.conf

Settings: Default filter workers: 2

Logstash startup completed

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 生产配置文件,输入redis:
  • 生产配置文件,redis读出:
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档