-
Notifications
You must be signed in to change notification settings - Fork 0
/
logstash-input-algolialogs.conf
56 lines (49 loc) · 1.2 KB
/
logstash-input-algolialogs.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
input {
algolialogs {
application_id => "YOUR_APPID"
api_key => "YOUR_APIKEY"
length => 1000
interval => 60
}
}
filter {
# add geoip informations
geoip {
source => "ip"
}
# transform params to be searchable
ruby {
code => "require 'cgi'
if (event['query_params'])
event['query_params'] = CGI::parse(event['query_params'])
end"
}
# parse headers and keep just necessary
ruby {
code => "require 'net/http'
event['headers'] = {}
event['query_headers'].each_line { |line|
params = line.split(': ')
if (params[0] == 'User-Agent' || params[0] == 'Referer' || params[0] == 'Origin')
event['headers'][params[0].downcase] = params[1]
end
}"
}
# translate user agent
useragent {
source => "[headers][user-agent]"
target => "[headers][useragent]"
}
# remove unusual fields and convert some string to integer
mutate {
remove_field => [ "answer", "url", "ip", "[headers][user-agent]", "query_body", "query_headers"]
convert => { "nb_api_calls" => "integer" }
convert => { "processing_time_ms" => "integer" }
convert => { "query_nb_hits" => "integer" }
}
}
output {
stdout {
codec => rubydebug
}
}