-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlogstash.conf
67 lines (66 loc) · 2.07 KB
/
logstash.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
input {
beats {
port => "5044"
}
}
filter {
if "gorlogs" in [tags] {
ruby {
code => "
array = event.get('message').split(' ')
array.each_with_index do |item, index|
if item == 'Host:'
event.set('Host:', array[index + 1])
elsif item == 'GET'
event.set('Method', 'GET')
event.set('Url', array[index + 1])
elsif item == 'POST'
event.set('Method', 'POST')
event.set('Url', array[index + 1])
elsif item == 'User-Agent:'
event.set('User-Agent', array[index + 1])
elsif item == 'user-agent:'
temp = ''
i = index
until array[i + 1].include?('accept') do
temp = temp + array[i + 1] + ' '
i += 1
end
event.set('user-agent', temp)
elsif item == 'X-Real-IP:'
event.set('clientip', array[index + 1])
end
end
"
remove_field => ['host', '@version', '_version', 'input', 'prospector', 'beat', 'message', 'offset', 'log']
}
geoip {
source => "clientip"
target => "geoip"
fields => ["country_name", "region_name", "city_name", "location", "ip"]
}
useragent {
source => "user-agent"
target => "devices"
}
}
if "normallogs" in [tags] {
json {
source => "message"
}
}
}
output {
if "gorlogs" in [tags] {
elasticsearch {
hosts => [ "localhost:9200" ]
index => "logstash-gor-%{+YYYY.MM.dd}"
}
}
if "normallogs" in [tags] {
elasticsearch {
hosts => [ "localhost:9200" ]
index => "logstash-%{+YYYY.MM.dd}"
}
}
}