Sha256: d4689fd9dc176b50f28dda9342b2d30de900f4f8df548f657fbbae93b0741f59
Contents?: true
Size: 969 Bytes
Versions: 1
Compression:
Stored size: 969 Bytes
Contents
require 'docker' module Fluent class Dockerid2Name < Filter Fluent::Plugin.register_filter('docker_hostname', self) config_param :docker_url, :string, :default => 'unix:///var/run/docker.sock' def configure(conf) super Docker.url = @docker_url @containerid_hash = Hash.new end 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 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[:app_name] = @containerid_hash[container_id] new_es.add(time, record) } return new_es end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-docker_hostname-0.1.0 | lib/fluent/plugin/filter_docker_image_name.rb |