input {
file {
type => "tomcat-catalina"
path => "/u02/8080-tomcat/logs/catalina.out"
codec => multiline {
pattern => "^\s"
what => "previous"
}
}
}
output {
redis {
host => "172.17.17.15"
port => 6379
data_type => "list"
key => "logstash-tomcat-catalina"
}
}
input {
redis {
host => "172.17.17.15"
port => 6379
data_type => "list"
key => "logstash-tomcat-catalina"
}
}
filter {
ruby {
code => "event['filedatetag'] = event.timestamp.time.localtime.strftime('%Y-%m-%d')"
}
}
output {
file {
path => "/data/log/tomcat/%{host}/catalina-%{filedatetag}.log"
message_format=>"%{host}----%{message}"
}
#stdout{
# codec=>rubydebug
#}
if [message] =~ "Exception" {
file {
path => "/data/log/tomcat/exception/exception-%{filedatetag}.log"
}
}
}
客户端上的配置
vim /usr/local/logstash/etc/nginx_log.cnf
input {
file {
type => "nginx_access_log"
path => "/data/logs/nginx/access_log.log"
}
file {
type => "nginx_access"
path => "/data/logs/nginx/access.log"
}
file {
type => "nginx_access_check"
path => "/data/logs/nginx/access_check.log"
}
}
output {
redis {
host => "172.17.17.15"
port => 6379
data_type => "list"
key => "logstash-nginx-log"
}
}
日志服务器上的配置
vim /usr/local/logstash/etc/nginx_log.cnf
input {
redis {
host => "172.17.17.15"
port => 6379
data_type => "list"
key => "logstash-nginx-log"
}
}
filter {
ruby {
code => "event['filedatetag'] = event.timestamp.time.localtime.strftime('%Y-%m-%d')"
}
}
output {
file {
path => "/data/log/nginx/%{host}/%{type}/%{type}-%{filedatetag}.log"
message_format=>"%{message}"
}
}
input {
redis {
host => "172.17.17.15"
port => 6379
data_type => "list"
key => "logstash-nginx-log"
}
}
filter {
ruby {
code => "event['filedatetag'] = event.timestamp.time.localtime.strftime('%Y-%m-%d')"
}
json {
source => "message"
target => "jsoncontent"
}
}
output {
file {
path => "/data/log/nginx/all/%{type}/%{type}-%{filedatetag}.log"
message_format=>"%{message}"
#message_format=>"%{host}----%{type}----%{message}"
}
if [message] =~ "code=514" {
file {
path => "/data/log/nginx/zabbix_monitor/yunxin-code514.log"
message_format=>"%{message}"
}
}
exec {
command => "/usr/local/redis/bin/redis-cli -h 127.0.0.1 incr zabbix_nginx_log_count_%{type}"
}
exec {
command => "/usr/local/redis/bin/redis-cli -h 127.0.0.1 incr zabbix_nginx_log_count_%{type}_%{[jsoncontent][status]}"
}
#stdout{
# codec=>rubydebug
#}
}