class Fluent::DockerHostname
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_docker_hostname.rb, line 9 def configure(conf) super Docker.url = @docker_url @containerid_hash = Hash.new end
filter_stream(tag, es)
click to toggle source
# File lib/fluent/plugin/filter_docker_hostname.rb, line 30 def filter_stream(tag, es) new_es = MultiEventStream.new container_id = tag.match(/(\w{64})/) @containerid_hash[container_id] ||= get_appname(container_id) es.each {|time, record| record[:container_hostname] = @containerid_hash[container_id] new_es.add(time, record) } return new_es end
get_appname(container_id)
click to toggle source
# File lib/fluent/plugin/filter_docker_hostname.rb, line 16 def get_appname(container_id) Docker::Container.all.each do |obj| container_json = obj.json if container_id.to_s == container_json['Id'].to_s config = container_json['Config'] return config['Hostname'] end end return nil end