-
Notifications
You must be signed in to change notification settings - Fork 0
/
fortigate.conf
86 lines (78 loc) · 2.13 KB
/
fortigate.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
input {
udp {
host => "0.0.0.0"
port => 5044
}
}
filter {
mutate {
add_field => ["[event][created]", "%{@timestamp}"] # event.created: when the event is created by logstash
}
# Captura o PRI do syslog e separa a mensagem
grok {
match => ["[event][original]", "<%{NUMBER:syslog_pri}>%{GREEDYDATA:[@metadata][message]}"]
tag_on_failure => ["fortinet_grok_failure"]
}
if "fortinet_grok_failure" not in [tags] {
# Calcula a Facility e o Severity a partir do PRI
ruby {
code => "
pri = event.get('syslog_pri').to_i
facility = pri / 8
severity = pri % 8
event.set('facility_code', facility)
event.set('severity_code', severity)
"
}
kv {
source => "[@metadata][message]"
value_split => "="
field_split => " "
whitespace => strict
target => "fct"
}
# Ajusta o timezone se não estiver presente
if ![fct][tz] {
mutate {
replace => {"[fct][tz]" => "-0500"}
add_tag => ["setting_default_timezone"]
}
}
mutate {
replace => {"[@metadata][timestamp]" => "%{[fct][date]} %{[fct][time]} %{[fct][tz]}"}
}
date {
match => ["[@metadata][timestamp]", "yyyy-MM-dd HH:mm:ss Z"]
target => "@timestamp"
}
}
}
output {
# Condição para envio ao índice correto com base no código da facility
if [facility_code] == 20 {
elasticsearch {
index => "fortigate-trafego-logs-%{+YYYY.MM.dd}"
hosts => "${ELASTIC_HOSTS}"
user => "${ELASTIC_USER}"
password => "${ELASTIC_PASSWORD}"
cacert => "certs/ca/ca.crt"
}
} else if [facility_code] == 21 {
elasticsearch {
index => "fortigate-seguranca-logs-%{+YYYY.MM.dd}"
hosts => "${ELASTIC_HOSTS}"
user => "${ELASTIC_USER}"
password => "${ELASTIC_PASSWORD}"
cacert => "certs/ca/ca.crt"
}
} else {
# Logs com facility desconhecida
elasticsearch {
index => "fortigate-desconhecido-logs-%{+YYYY.MM.dd}"
hosts => "${ELASTIC_HOSTS}"
user => "${ELASTIC_USER}"
password => "${ELASTIC_PASSWORD}"
cacert => "certs/ca/ca.crt"
}
}
}