filter {
ruby {
code => '
num = 0
for i in ["system_start","unknown","interactive","network","batch","service","unknown","unlock","network_cleartext","new_credentials","rdp","cache_interactive"]
if event.get("[event_data][LogonType]").match("#{num}")
event.set("logon_type","#{i}")
end
num += 1
end
'
}
}
mutate 플러그인과는 차원이 다른 우아함.
filter {
if [event_data][LogonType] == "0" {
mutate { replace => { "[event_data][LogonType]" => "system_start" } }
}
if [event_data][LogonType] == "2" {
mutate { replace => { "[event_data][LogonType]" => "interactive" } }
}
if [event_data][LogonType] == "3" {
mutate { replace => { "[event_data][LogonType]" => "network" } }
}
if [event_data][LogonType] == "4" {
mutate { replace => { "[event_data][LogonType]" => "batch" } }
}
if [event_data][LogonType] == "5" {
mutate { replace => { "[event_data][LogonType]" => "service" } }
}
if [event_data][LogonType] == "7" {
mutate { replace => { "[event_data][LogonType]" => "unlock" } }
}
if [event_data][LogonType] == "8" {
mutate { replace => { "[event_data][LogonType]" => "network_cleartext" } }
}
if [event_data][LogonType] == "9" {
mutate { replace => { "[event_data][LogonType]" => "new_credentials" } }
}
if [event_data][LogonType] == "10" {
mutate { replace => { "[event_data][LogonType]" => "rdp" } }
}
if [event_data][LogonType] == "11" {
mutate { replace => { "[event_data][LogonType]" => "cache_interactive" } }
}
}
그런데 mutate는 번거롭고 ruby는 익숙치 않다면? 이때 translate 플러그인 추천.
translate {
field => "[event_data][LogonType]"
destination => "[event_data][LogonType]"
dictionary => [
"0", "system_start",
"2", "interactive",
"3", "network",
"4", "batch",
"5", "service",
"7", "unlock",
"8", "network_cleartext",
"9", "new_credentials",
"10", "rdp",
"11", "cache_interactive"
]
override => true
}
기존 필드를 덮어씌우려면 'override => true' 옵션을 사용하면 된다.
관련 글
- Logstash 필터 grok
- Logstash 필터 mutate
- Logstash 필터 ruby
- Logstash 필터 geoip
- Logstash 필터 dissect
- Logstash 필터 kv
- Logstash 필터 date
- Logstash 필터 drop
- Logstash 필터 useragent
- Logstash 필터 elapsed
- logstash 필터 fingerprint
- Logstash 필터 csv
- Logstash 필터 dns
- Logstash codec 플러그인 multiline
댓글 없음:
댓글 쓰기