Class: LogStash::Filters::DockerContainer
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::DockerContainer
- Defined in:
- lib/logstash/filters/docker_container.rb
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/logstash/filters/docker_container.rb', line 25 def filter(event) return unless filter? event @match.each { |in_field,out_field| event.set(out_field, resolve_from(event.get(in_field))) } filter_matched(event) end |
#register ⇒ Object
18 19 20 21 22 |
# File 'lib/logstash/filters/docker_container.rb', line 18 def register # Add instance variables @inspector = LogStash::Filters::DockerContainerSupport::DockerContainerInspector.new(@docker_client, @client_options) @cached = Hash.new end |
#resolve_from(container_id) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/logstash/filters/docker_container.rb', line 35 def resolve_from(container_id) if @cached.has_key?(container_id) return @cached[container_id] end blob = @inspector.inspect container_id details = JSON.parse(blob) return nil if details.empty? detail = details.first @cached[container_id] = detail['Name'] end |