#Sample Logstash configuration for creating a simple
|
# Beats - > Logstash - > Elasticsearch pipeline.
|
|
input {
|
beats {
|
port => 5044
|
}
|
}
|
|
filter {
|
|
ruby {
|
code => "event.set('timestamp', event.get('@timestamp').time.localtime + 8*60*60)"
|
}
|
ruby {
|
code => "event.set('@timestamp',event.get('timestamp'))"
|
}
|
if [fields][app] == "buwan" {
|
if [fields][type] == "videoPlay" {
|
grok {
|
match => {
|
"message" =>
|
"%{TIMESTAMP_ISO8601:time}\s*\[%{DATA:thread}\]\s*%{LOGLEVEL:logLevel}\s*%{WORD:logName}\s*-\s*%{WORD:method}\:%{NUMBER:detailSystemId}#%{NUMBER:videoId}#"
|
}
|
}
|
|
mutate {
|
remove_field => ["message"]
|
remove_field => ["input"]
|
remove_field => ["tags"]
|
remove_field => ["meta"]
|
remove_field => ["host"]
|
remove_field => ["timestamp"]
|
}
|
}
|
if [fields][type] == "videoPlayUser" {
|
grok {
|
match => {
|
"message" =>
|
"%{TIMESTAMP_ISO8601:time}\s*\[%{DATA:thread}\]\s*%{LOGLEVEL:logLevel}\s*%{WORD:logName}\s*-\s*%{WORD:method}\:%{UUID:device}#(?<utdId>([\S+]*))#(?<loginUid>([0-9]*))#%{NUMBER:detailSystemId}#%{NUMBER:videoId}#%{NUMBER:resourceId}#(?<from>([\S+]*))"
|
}
|
}
|
|
mutate {
|
remove_field => ["message"]
|
remove_field => ["input"]
|
remove_field => ["tags"]
|
remove_field => ["meta"]
|
remove_field => ["host"]
|
remove_field => ["timestamp"]
|
}
|
|
}
|
if [fields][type] == "userActive" {
|
grok {
|
match => {
|
"message" =>
|
"%{TIMESTAMP_ISO8601:time}\s*\[%{DATA:thread}\]\s*%{LOGLEVEL:logLevel}\s*%{WORD:logName}\s*-\s*%{NUMBER:detailSystemId}#%{NUMBER:version}#%{UUID:device}#(?<utdId>([\S+]*))#(?<loginUid>([0-9]*))#%{WORD:type}#(?<params1>([\S+]*))#(?<params2>([\S+]*))#(?<params3>([\S+]*))"
|
}
|
}
|
|
mutate {
|
remove_field => ["message"]
|
remove_field => ["input"]
|
remove_field => ["tags"]
|
remove_field => ["meta"]
|
remove_field => ["host"]
|
remove_field => ["timestamp"]
|
}
|
|
}
|
}
|
}
|
|
output {
|
if [fields][app] == "buwan" {
|
if [fields][type] == "videoPlay" {
|
file {
|
path => "D:/logs/buwan/videoplay/%{+yyyy}_%{+MM}_%{+dd}.log"
|
}
|
|
} else if [fields][type] == "videoPlayUser" {
|
file {
|
path => "D:/logs/buwan/videoplay-user/%{+yyyy}_%{+MM}_%{+dd}.log"
|
}
|
} else if [fields][type] == "userActive" {
|
file {
|
path => "D:/logs/buwan/user/active_%{+yyyy}_%{+MM}_%{+dd}.log"
|
}
|
} else if [fields][type] == "error" {
|
file {
|
path => "D:/logs/buwan/error/%{+yyyy}_%{+MM}_%{+dd}.log"
|
}
|
} else if [fields][type] == "videoUpdate" {
|
file {
|
path => "D:/logs/buwan/video_update/%{+yyyy}_%{+MM}_%{+dd}.log"
|
}
|
}
|
}
|
}
|