fluent-plugin-docker_hostname 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad8246e7301cc0a78b3f18cff7b1f3027500cd2f
4
- data.tar.gz: b54814ead33040fb62fa5cfb52f0cdfb5112d849
3
+ metadata.gz: 193433ae1731af38a2de337717a6b20f7e985b2f
4
+ data.tar.gz: d8c0e28c010e49751eb9940107972ad5979fdd6c
5
5
  SHA512:
6
- metadata.gz: 0b87fcd12215f41b68fd981cb6a4134b012d9e64ec499f48ee7650351c5cfb57cf586edf645dbc51bab006809e4d3b872c8284eb41ef7b6a5c2e336758e102af
7
- data.tar.gz: e27fb636e3c9a7a1a35bde6cf9ab12cca2a2c02898d251a2300c8e07c1fee2b02f64593b4ffd06b7e9ebe3653f346929b38fc6bcc4d7decaedde99528ecdfe3d
6
+ metadata.gz: 3d81258a32b2af126d5f136ef9191edcd3671dc9c9f7fcd5abba6a4587910924c724f6e4c43190767d7c78da0c1063345124995f495925e7dae394e94e80c754
7
+ data.tar.gz: ea41d8469dc13973c97fd2b1f5e77fc5cc4182f9e5aa3e8035fd270fb9fcad9ec15a9c5c8841f1174d139f70ff96f5488fc5d3b1acdeadf8fb653b71a9284a78
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-docker_hostname"
7
- spec.version = "0.1.1"
7
+ spec.version = "0.1.2"
8
8
  spec.authors = ["Woorank"]
9
9
  spec.email = ["dev@woorank.com"]
10
10
  spec.summary = "Output container's hostname for a given docker container's id"
@@ -0,0 +1,45 @@
1
+ require 'docker'
2
+
3
+ module Fluent
4
+ class Fluent::DockerHostname < Filter
5
+ Fluent::Plugin.register_filter('docker_hostname', self)
6
+
7
+ config_param :docker_url, :string, :default => 'unix:///var/run/docker.sock'
8
+
9
+ def configure(conf)
10
+ super
11
+
12
+ Docker.url = @docker_url
13
+ @containerid_hash = Hash.new
14
+ end
15
+
16
+ def get_appname(container_id)
17
+ Docker::Container.all.each do |obj|
18
+ container_json = obj.json
19
+
20
+ if container_id.to_s == container_json['Id'].to_s
21
+ config = container_json['Config']
22
+
23
+ return config['Hostname']
24
+ end
25
+ end
26
+
27
+ return nil
28
+ end
29
+
30
+ def filter_stream(tag, es)
31
+ new_es = MultiEventStream.new
32
+
33
+ container_id = tag.match(/(\w{64})/)
34
+ @containerid_hash[container_id] ||= get_appname(container_id)
35
+
36
+ es.each {|time, record|
37
+ record[:app_name] = @containerid_hash[container_id]
38
+ new_es.add(time, record)
39
+ }
40
+
41
+ return new_es
42
+ end
43
+
44
+ end
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-docker_hostname
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Woorank
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - fluent-plugin-docker_hostname.gemspect
68
+ - lib/fluent/plugin/filter_docker_hostname.rb
68
69
  homepage: https://github.com/Woorank/fluent-plugin-docker_hostname
69
70
  licenses:
70
71
  - MIT