fluent-plugin-dockerevents 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 509d1174b298bb783dfb80f0aeecde1a9a2c34c5
4
- data.tar.gz: 19d2b3f54371188329b59b605ffe9783ddebfbe2
3
+ metadata.gz: 71357c18e83c8e7a1d3b111225323ffd659a369d
4
+ data.tar.gz: e2488f5bc7737b2f305aa770d30a3420602877ff
5
5
  SHA512:
6
- metadata.gz: ffdddecd32b02d92a2712befb4d63ede082dc712661dfcc79cdc28c06c26fe54d63efd13cd0fbbc00b439f0d75631d52384aefdba31a0480fcba62760673f5af
7
- data.tar.gz: ebb408231a5a20bfa6d3117e32823c407198e1d3ead469910c78800f1ecc4220ed0165db50a33aadd5c9e3ea4b9da24bcc0aa62b649dfe7a40c440b1cf1e1b76
6
+ metadata.gz: 6d1f303899c02e1ca688bc690968eab9dcbbba8c0d5e7113c51f81fd0da2587d940e0ed3472e7e5f7422702d9a4864bc26c7d78b5e0db74c9f03a24bd9b52885
7
+ data.tar.gz: 3499a62d87c6e74e3d7722c0c7cdc5db678466fe735cdf0bcfbebc6c1ade99043af3652807fbb9db2e752b910e8ab64e4bc3d6492e86f1da88a22ac524b6fa9e
data/RELEASE.md ADDED
@@ -0,0 +1,5 @@
1
+
2
+ Release notes
3
+
4
+ # v.0.0.3
5
+ * Bugfix: Fix hanginx docker API call with having the request in separate threads
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-dockerevents"
6
- s.version = '0.0.2'
6
+ s.version = '0.0.3'
7
7
  s.authors = ["Karoly Nagy"]
8
8
  s.email = ["dr.karoly.nagy@gmail.com"]
9
9
  s.description = %q{Docker Event Stream inpupt plugin for Fluentd}
@@ -0,0 +1,66 @@
1
+ module Fluent
2
+ class DockerEventStreamInput < Input
3
+ Fluent::Plugin.register_input('docker_events', self)
4
+
5
+ config_param :tag, :string, :default => "docker"
6
+ config_param :events, :string, :default => []
7
+
8
+ # Define `router` method of v0.12 to support v0.10 or earlier
9
+ unless method_defined?(:router)
10
+ define_method("router") { Fluent::Engine }
11
+ end
12
+
13
+ def initialize
14
+ super
15
+ require 'docker'
16
+ end
17
+
18
+ def configure(conf)
19
+ super
20
+ @events = @events.split(',').map {|event| event.strip }
21
+ end
22
+
23
+ def start
24
+ super
25
+
26
+ @running = true
27
+ @thread = Thread.new(&method(:run))
28
+ end
29
+
30
+ def shutdown
31
+ @running = false
32
+ @thread.join
33
+ end
34
+
35
+ def run
36
+ while @running
37
+ Docker::Event.stream do |event|
38
+ if @events.include?(event.action)
39
+ emit(event)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def emit(r)
46
+ record = {
47
+ "id" => r.id,
48
+ "action" => r.action,
49
+ "status" => r.status,
50
+ "type" => r.type,
51
+ }
52
+ _container = Docker::Container.get(r.id)
53
+ if _container
54
+ record["container"] = {
55
+ "state" => _container.info["State"],
56
+ "name" => _container.info["Name"].gsub(/^\//, ''),
57
+ }
58
+ _image = Docker::Image.get(_container.info["Image"])
59
+ if _image
60
+ record["container"]["image"] = _image.info["RepoTags"]
61
+ end
62
+ end
63
+ router.emit(@tag, Time.now.to_i, record)
64
+ end
65
+ end
66
+ end
@@ -49,13 +49,13 @@ module Fluent
49
49
  "status" => r.status,
50
50
  "type" => r.type,
51
51
  }
52
- _container = Docker::Container.get(r.id)
52
+ _container = Thread.new{ results = Docker::Container.get(r.id) }.value
53
53
  if _container
54
54
  record["container"] = {
55
55
  "state" => _container.info["State"],
56
56
  "name" => _container.info["Name"].gsub(/^\//, ''),
57
57
  }
58
- _image = Docker::Image.get(_container.info["Image"])
58
+ _image = Thread.new{ results = Docker::Image.get(_container.info["Image"]) }.value
59
59
  if _image
60
60
  record["container"]["image"] = _image.info["RepoTags"]
61
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-dockerevents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karoly Nagy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -103,8 +103,10 @@ files:
103
103
  - Gemfile
104
104
  - LICENSE
105
105
  - README.md
106
+ - RELEASE.md
106
107
  - example/in.docker.events.conf
107
108
  - fluent-plugin-dockerevents.gemspec
109
+ - lib/fluent/plugin/in_docker_event_streams.rb
108
110
  - lib/fluent/plugin/in_docker_events.rb
109
111
  homepage: https://github.com/charlesnagy/fluent-plugin-docker-events
110
112
  licenses: