ELKStack-生产案例项目实战(十一)

ELKStack-生产案例项目实战

1、收集ES和apache日志,入redis

input {
    file {
        path => "/etc/httpd/logs/access_log"
        start_position => "beginning"
        type => "apache-accesslog"
    }
	file{
        path => "/var/log/elasticsearch/myes.log"
        type => "es-log"
        start_position => "beginning"
        codec => multiline{
            pattern => "^\["
            negate => true
            what => "previous"
        }
    }
}


output{
    if [type] == "es-log" {
	    redis {
            host => ["192.168.137.11"]
            port => 6379
            db => 1
            data_type => "list"
            key => "es-log"
            timeout => 10
        }
    }
    if [type] == "apache-accesslog" {
        redis {
            host => ["192.168.137.11"]
            port => 6379
            db => 1
            data_type => "list"
            key => "apache-accesslog"
            timeout => 10
        }
    }
}

启动/opt/logstash/bin/logstash -f /etc/logstash/conf.d/shipper.conf

2、通过syslog服务端主机,获取所有的客户端主机的syslog和redis中数据,写入ES

input{
    syslog {
        type => "system-syslog"
        port => 514
    }
	redis {
        type => "es-log"
		host => ["192.168.137.11"]
		port => 6379
		db => 1
		data_type => "list"
		key => "es-log"
		timeout => 10
	}
	redis {
        type => "apache-accesslog"
		host => ["192.168.137.11"]
		port => 6379
		db => 1
		data_type => "list"
		key => "apache-accesslog"
		timeout => 10
	}
}

filter {
    if [type] == "apache-accesslog" {
        grok {
            match => { "message" => "%{COMBINEDAPACHELOG}" }
        }
    }
}

output{
    if [type] == "apache-accesslog" {
	    elasticsearch {
            hosts => ["192.168.137.11:9200"]
            index => "apache-accesslog-%{+YYYY.MM.dd}"
        }
    }
    if [type] == "es-log" {
        elasticsearch {
            hosts => ["192.168.137.11:9200"]
            index => "es-log-%{+YYYY.MM}"
        }
    }
    if [type] == "system-syslog" {
        elasticsearch {
            hosts => ["192.168.137.11:9200"]
            index => "system-syslog-%{+YYYY.MM}"
        }
    }
}

启动/opt/logstash/bin/logstash -f /etc/logstash/conf.d/redis-es.conf

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值