Skip to content

Instantly share code, notes, and snippets.

@dcode
Last active February 11, 2020 19:33
Show Gist options
  • Select an option

  • Save dcode/b43ff913b2661775c02b2e9b28029fa8 to your computer and use it in GitHub Desktop.

Select an option

Save dcode/b43ff913b2661775c02b2e9b28029fa8 to your computer and use it in GitHub Desktop.
filter {
cidr {
add_tag => [ "local_source" ]
address => [ "%{[source][ip]}" ]
network => [ "10.0.0.0/8", "172.16.0.0/20", "192.168.0.0/16" ]
}
cidr {
add_tag => [ "local_destination" ]
address => [ "%{[destination][ip]}" ]
network => [ "10.0.0.0/8", "172.16.0.0/20", "192.168.0.0/16" ]
}
if "local_source" in [tags] {
if "local_destination" in [tags] {
mutate {
add_field => { [network][direction] => "internal" }
remove_tag => [ "local_source", "local_destination" ]
}
} else {
mutate {
add_field => { [network][direction] => "outbound" }
remove_tag => [ "local_source" ]
}
}
} else {
if "local_destination" in [tags] {
mutate {
add_field => { [network][direction] => "inbound" }
remove_tag => [ "local_destination" ]
}
} else {
mutate {
add_field => { [network][direction] => "external" }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment