Class: LogStash::Filters::Ipam
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Ipam
- Defined in:
- lib/logstash/filters/ipam.rb
Overview
This filter will replace the contents of the default message field with whatever you specify in the configuration.
It is only intended to be used as an .
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/logstash/filters/ipam.rb', line 123 def filter(event) # Check file # if doesn't exist => create with content. # if need reset => update content. checkFile(event) # Get Subnets from updated file # if can't read => Warning ipamSubnets = getIpamSubnets(event) # Get Subnets that contains IP # if @gateway => Get 0.0.0.0 subnets # else => Don't get those subnets # if !ipv4 => Don't handle those subnets subnets = checkIpSubnets(@ip, subnets) # Set field only if there is some subnets checked. if subnets.length > 0 event.set(@field, subnets) else # filter_matched should go in the last line of our successful code filter_matched(event) end end |
#register ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/logstash/filters/ipam.rb', line 37 def register # Check if the IP string is an actual IP, or stop process begin @ip = IPAddr.new(@ip) rescue ArgumentError => e @logger.warn("Invalid IP address, skipping", :address => @ip, :event => event) nil end end |