fluent-plugin-docker-inspect 0.0.2 → 0.0.3
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 +4 -4
- data/README.rst +25 -11
- data/VERSION +1 -1
- data/lib/fluent/plugin/in_docker_inspect.rb +37 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 594dfb450c0523dea0239c2e45a266990805f166
|
4
|
+
data.tar.gz: a8c25679540b4d60b73524b0340dc2b7a0da4d24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8f897f41694ad4a0aef7a89871a7de736587bcf398b37a7cc812ecbf2d806d3d8f1af01f6666d67e560f9a40d4776ac05d49441c86f90b8816a14001fc5e95
|
7
|
+
data.tar.gz: 77578301ea7b698b62fdf39f667b77684ba055856707247dbd852fb0727bf4f48dc7bb19dec97c9f765da726b07c3c49c355d53cdf03551d1eb3b38f5a537e46
|
data/README.rst
CHANGED
@@ -19,24 +19,38 @@ Configuration
|
|
19
19
|
|
20
20
|
::
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
<source>
|
23
|
+
type docker_inspect
|
24
|
+
emit_interval 30
|
25
|
+
tag docker.inspects
|
26
|
+
add_addr_tag yes
|
27
|
+
filter { "status": ["running"] } # see Docker remote API
|
28
|
+
only_changed true
|
29
|
+
<keys>
|
30
|
+
id Id
|
31
|
+
created Created
|
32
|
+
path Path
|
33
|
+
status State.Status
|
34
|
+
ports NetworkSettings.Ports
|
35
|
+
ip_addr NetworkSettings.IPAddress
|
36
|
+
mac_addr NetworkSettings.MacAddress
|
37
|
+
</keys>
|
38
|
+
</source>
|
29
39
|
|
30
40
|
emit_interval
|
31
|
-
|
41
|
+
Emit interval by second. (default 60 sec)
|
32
42
|
tag
|
33
43
|
fluentd tag.
|
34
44
|
docker_url
|
35
|
-
|
45
|
+
Specify docker_url if remote. ex: ``tcp://example.com:5422``. If docker runs local, no need to specify this param.
|
36
46
|
add_addr_tag
|
37
|
-
|
47
|
+
If specify some string such as 'yes', add local host ipv4 addr. (default: nil).
|
48
|
+
filter
|
49
|
+
Set fileter about container. See Docker remote API to specify params.
|
38
50
|
only_changed
|
39
|
-
|
51
|
+
If true, only emit when docker inspect is changed. (default is true)
|
52
|
+
keys
|
53
|
+
If set, output values containes only specified keys and path(period separated value). Default is output all values as one JSON.
|
40
54
|
|
41
55
|
License
|
42
56
|
----------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -1,3 +1,15 @@
|
|
1
|
+
# convert dot-string to value in hash
|
2
|
+
# ex: NetworkSettings.Ports -> hash[NetworkSettings][Ports]
|
3
|
+
def dig(hash, dotted_path)
|
4
|
+
parts = dotted_path.split '.', 2
|
5
|
+
match = hash[parts[0]]
|
6
|
+
if !parts[1] or match.nil?
|
7
|
+
return match
|
8
|
+
else
|
9
|
+
return dig(match, parts[1])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
1
13
|
module Fluent
|
2
14
|
class DockerInspectInput < Input
|
3
15
|
Fluent::Plugin.register_input('docker_inspect', self)
|
@@ -7,7 +19,7 @@ module Fluent
|
|
7
19
|
config_param :tag, :string, :default => nil
|
8
20
|
config_param :add_addr_tag, :string, :default => nil
|
9
21
|
config_param :filter, :string, :default => nil
|
10
|
-
config_param :only_changed, :
|
22
|
+
config_param :only_changed, :bool, :default => true
|
11
23
|
|
12
24
|
unless method_defined?(:log)
|
13
25
|
define_method(:log) { $log }
|
@@ -47,6 +59,16 @@ module Fluent
|
|
47
59
|
|
48
60
|
def configure(conf)
|
49
61
|
super
|
62
|
+
|
63
|
+
# Read configuration for keys and create a hash
|
64
|
+
@keys = Hash.new
|
65
|
+
conf.elements.select { |element| element.name == 'keys' }.each { |element|
|
66
|
+
element.each_pair { |key_name, path|
|
67
|
+
element.has_key?(key_name) # to suppress unread configuration warning
|
68
|
+
@keys[key_name] = path
|
69
|
+
@log.info "Added keys: #{key_name}=>#{@keys[key_name]}"
|
70
|
+
}
|
71
|
+
}
|
50
72
|
end
|
51
73
|
|
52
74
|
def start
|
@@ -87,7 +109,19 @@ module Fluent
|
|
87
109
|
return
|
88
110
|
end
|
89
111
|
inspect.each { | i |
|
90
|
-
@
|
112
|
+
if @keys.length > 0 # keys are specfied
|
113
|
+
k = Hash.new
|
114
|
+
changed = false
|
115
|
+
@keys.each do |key_name, path|
|
116
|
+
tmp = dig(i, path)
|
117
|
+
next if tmp == ""
|
118
|
+
k[key_name] = tmp
|
119
|
+
changed = true # if nothing matched, not sent
|
120
|
+
end
|
121
|
+
@es.add(time, k) if changed
|
122
|
+
else
|
123
|
+
@es.add(time, i)
|
124
|
+
end
|
91
125
|
}
|
92
126
|
router.emit_stream(tag, @es)
|
93
127
|
end
|
@@ -121,6 +155,7 @@ module Fluent
|
|
121
155
|
get_containers.each { |c|
|
122
156
|
result.push c.json
|
123
157
|
}
|
158
|
+
# check changed before or not
|
124
159
|
if @only_changed && @last_inspect.to_s == result.to_s
|
125
160
|
return []
|
126
161
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-docker-inspect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WAKAYAMA Shirou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|