SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
НазадМетки: logstash mikrotik netflow
Создаём файл /etc/logstash/conf.d/logstash-netflow.conf
# Указание слушать порт 9995
input {
    udp {
        port => 9995
        type => netflow
        codec => netflow {
            versions => [5,9,10]
        }
    }
}
filter {
    translate {
        field => "[netflow][protocol]"
        destination => "[protocol_name]"
        override => "true"
        dictionary => [
            "6", "TCP",
            "17", "UDP",
            "1", "ICMP",
            "47", "GRE",
            "50", "ESP",
            "89", "OSPFIGP"
        ]
    }
    mutate {
        add_field => { "ipv4_src_host" => "%{[netflow][ipv4_src_addr]}" }
        add_field => { "ipv4_dst_host" => "%{[netflow][ipv4_dst_addr]}" }
    }
    cidr {
        add_field => { "interesting" => true }
        address => [ "%{[netflow][ipv4_src_addr]}", "%{[netflow][ipv4_dst_addr]}" ]
        network => [ "192.168.0.0/24" ]
    }
}
output {
    if ( [type] == "netflow" ) {
        elasticsearch {
            hosts => "127.0.0.1:9200"
            index => "netflow-%{+YYYY.MM.dd}"
        }
    }
}
Устанавливаем плагины
cd /usr/share/logstash/ bin/logstash-plugin install logstash-codec-netflow bin/logstash-plugin install logstash-codec-sflow bin/logstash-plugin install logstash-filter-translate bin/logstash-plugin install logstash-input-udp bin/logstash-plugin install logstash-input-tcp bin/logstash-plugin install logstash-filter-dns bin/logstash-plugin install logstash-filter-geoip
Перезапускаем logstash
/ip traffic-flow
set cache-entries=16k enabled=yes interfaces=bridge
/ip traffic-flow target
add address=LOGSTASH_IP:9995 version=5