fluent-plugin-mqtt-io 0.3.5 → 0.3.6
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.md +18 -8
- data/fluent-plugin-mqtt-io.gemspec +1 -1
- data/lib/fluent/plugin/in_mqtt.rb +14 -4
- data/lib/fluent/plugin/out_mqtt.rb +15 -5
- 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: 6e38c839b0a95cb6cf2cebc4c54d2b6c7b40529c
|
4
|
+
data.tar.gz: 2070c495dd6162a84477057b41170b95880b82b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49a35a2dccbe28249c27731ac447a63d7f8462d0005486fa1736dc5f1316fa43ec46f09573ea758120b0d2c7dac8136b44f946e6cb7a3e16c39dac0b568eb5e1
|
7
|
+
data.tar.gz: d06614888b953bf57df4ab2110947f1ec77d2a489fe6bfcc27f0b1e3692397c140178d693aa6bb3981f807f9d32a5546cba9a8528a862c4ba8cf207a7d1d872b
|
data/README.md
CHANGED
@@ -76,8 +76,13 @@ The default MQTT topic is "#". Configurable options are the following:
|
|
76
76
|
- **ca_file**: CA certificate file path
|
77
77
|
- **key_file**: private key file path
|
78
78
|
- **cert_file**: certificate file path
|
79
|
-
- **recv_time**: Add receive time to message in millisecond (ms) as integer for debug and performance/delay analysis
|
80
|
-
- **recv_time_key**: An attribute of recv_time
|
79
|
+
- **recv_time**: Add receive time to message in millisecond (ms) as integer for debug and performance/delay analysis. only for fluent-plugin-mqtt-io <= 0.2.3
|
80
|
+
- **recv_time_key**: An attribute of recv_time. only for fluent-plugin-mqtt-io <= 0.2.3
|
81
|
+
- **monitor**: monitor section. only for fluent-plugin-mqtt-io ~> 0.3.0
|
82
|
+
- **recv_time**: Add receive time to message in millisecond (ms) as integer for debug and performance/delay analysis (default: false). only for fluent-plugin-mqtt-io ~> 0.3.0
|
83
|
+
- **recv_time_key**: An attribute of recv_time (default: "recv_time"). only for fluent-plugin-mqtt-io ~> 0.3.0
|
84
|
+
- **time_type**: Type of time format (string (default), unixtime, float) only for fluent-plugin-mqtt-io ~> 0.3.0
|
85
|
+
- **time_format**: Time format e.g. %FT%T.%N%:z (refer strftime) only for fluent-plugin-mqtt-io ~> 0.3.0
|
81
86
|
- **initial_interval**: An initial value of retry interval (s) (default 1)
|
82
87
|
- **retry_inc_ratio**: An increase ratio of retry interval per connection failure (default 2 (double)). It may be better to set the value to 1 in a mobile environment for eager reconnection.
|
83
88
|
- **max_retry_interval**: Maximum value of retry interval (default 300) only for fluent-plugin-mqtt-io ~> 0.3.0
|
@@ -118,13 +123,18 @@ For fluent-plugin-mqtt-io ~> v0.3.0
|
|
118
123
|
|
119
124
|
The options are basically the same as Input Plugin except for "format" and "bulk_trans" (only for Input). Additional options for Output Plugin are the following.
|
120
125
|
|
121
|
-
- time_key
|
126
|
+
- **time_key**: An attribute name used for timestamp field genarated from fluentd time field. Default is nil (omitted).
|
122
127
|
If this option is omitted, timestamp field is not appended to the output record.
|
123
|
-
- time_format
|
124
|
-
- topic_rewrite_pattern
|
125
|
-
- topic_rewrite_replacement
|
126
|
-
- send_time
|
127
|
-
- send_time_key
|
128
|
+
- **time_format**: Output format of timestamp field. Default is ISO8601. You can specify your own format by using TimeParser.
|
129
|
+
- **topic_rewrite_pattern**: Regexp pattern to extract replacement words from received topic or tag name
|
130
|
+
- **topic_rewrite_replacement**: Topic name used for the publish using extracted pattern
|
131
|
+
- **send_time**: Add send time to message in millisecond (ms) as integer for debug and performance/delay analysis. only for fluent-plugin-mqtt-io <= 0.2.3
|
132
|
+
- **send_time_key**: An attribute of send_time. only for fluent-plugin-mqtt-io <= 0.2.3
|
133
|
+
- **monitor**: monitor section. only for fluent-plugin-mqtt-io ~> 0.3.0
|
134
|
+
- **send_time**: Add send time to message in millisecond (ms) as integer for debug and performance/delay analysis. only for fluent-plugin-mqtt-io ~> 0.3.0
|
135
|
+
- **send_time_key**: An attribute of send_time. only for fluent-plugin-mqtt-io ~> 0.3.0
|
136
|
+
- **time_type**: Type of time format (string (default), unixtime, float) only for fluent-plugin-mqtt-io ~> 0.3.0
|
137
|
+
- **time_format**: Time format e.g. %FT%T.%N%:z (refer strftime) only for fluent-plugin-mqtt-io ~> 0.3.0
|
128
138
|
|
129
139
|
If you use different source, e.g. the other MQTT broker, log file and so on, there is no need to specifie topic rewriting. Skip the following descriptions.
|
130
140
|
|
@@ -6,6 +6,7 @@ require 'fluent/plugin/mqtt_proxy'
|
|
6
6
|
module Fluent::Plugin
|
7
7
|
class MqttInput < Input
|
8
8
|
include MqttProxy
|
9
|
+
include Fluent::TimeMixin::Formatter
|
9
10
|
|
10
11
|
Fluent::Plugin.register_input('mqtt', self)
|
11
12
|
|
@@ -25,12 +26,21 @@ module Fluent::Plugin
|
|
25
26
|
desc 'Record received time into message or not.'
|
26
27
|
config_param :recv_time, :bool, default: false
|
27
28
|
desc 'Specify the attribute name of received time.'
|
28
|
-
config_param :recv_time_key, :string, default:
|
29
|
+
config_param :recv_time_key, :string, default: 'recv_time'
|
30
|
+
desc 'Specify time type of recv_time (string, unixtime, float).'
|
31
|
+
config_param :time_type, :string, default: 'string'
|
32
|
+
desc 'Specify time format of recv_time (e.g. %FT%T.%N%:z).'
|
33
|
+
config_param :time_format, :string, default: nil
|
29
34
|
end
|
30
35
|
|
31
36
|
def configure(conf)
|
32
37
|
super
|
33
38
|
configure_parser(conf)
|
39
|
+
if !@monitor.nil?
|
40
|
+
@recv_time_formatter = time_formatter_create(
|
41
|
+
type: @monitor.time_type.to_sym, format: @monitor.time_format
|
42
|
+
)
|
43
|
+
end
|
34
44
|
end
|
35
45
|
|
36
46
|
def configure_parser(conf)
|
@@ -69,9 +79,9 @@ module Fluent::Plugin
|
|
69
79
|
end
|
70
80
|
|
71
81
|
def add_recv_time(record)
|
72
|
-
if @recv_time
|
82
|
+
if !@monitor.nil? && @monitor.recv_time
|
73
83
|
# recv_time is recorded in ms
|
74
|
-
record.merge({"#{@recv_time_key}": Fluent::EventTime.now})
|
84
|
+
record.merge({"#{@monitor.recv_time_key}": @recv_time_formatter.format(Fluent::EventTime.now)})
|
75
85
|
else
|
76
86
|
record
|
77
87
|
end
|
@@ -83,7 +93,6 @@ module Fluent::Plugin
|
|
83
93
|
log.debug "Since time_key field is nil, Fluent::EventTime.now is used."
|
84
94
|
time = Fluent::EventTime.now
|
85
95
|
end
|
86
|
-
log.debug "#{topic}, #{time}, #{add_recv_time(record)}"
|
87
96
|
return [time, add_recv_time(record)]
|
88
97
|
end
|
89
98
|
end
|
@@ -92,6 +101,7 @@ module Fluent::Plugin
|
|
92
101
|
begin
|
93
102
|
tag = topic.gsub("/","\.")
|
94
103
|
time, record = parse(message)
|
104
|
+
log.debug "MqttInput#emit: #{tag}, #{time}, #{add_recv_time(record)}"
|
95
105
|
if record.is_a?(Array)
|
96
106
|
mes = Fluent::MultiEventStream.new
|
97
107
|
record.each do |single_record|
|
@@ -6,6 +6,7 @@ require 'fluent/plugin/mqtt_proxy'
|
|
6
6
|
module Fluent::Plugin
|
7
7
|
class MqttOutput < Output
|
8
8
|
include MqttProxy
|
9
|
+
include Fluent::TimeMixin::Formatter
|
9
10
|
|
10
11
|
Fluent::Plugin.register_output('mqtt', self)
|
11
12
|
|
@@ -21,6 +22,10 @@ module Fluent::Plugin
|
|
21
22
|
config_param :send_time, :bool, default: false
|
22
23
|
desc 'Recording key name of send time for monitoring.'
|
23
24
|
config_param :send_time_key, :string, default: "send_time"
|
25
|
+
desc 'Specify time type of send_time (string, unixtime, float).'
|
26
|
+
config_param :time_type, :string, default: 'string'
|
27
|
+
desc 'Specify time format of send_time (e.g. %FT%T.%N%:z).'
|
28
|
+
config_param :time_format, :string, default: nil
|
24
29
|
end
|
25
30
|
|
26
31
|
# This method is called before starting.
|
@@ -32,6 +37,11 @@ module Fluent::Plugin
|
|
32
37
|
formatter_config = conf.elements(name: 'format').first
|
33
38
|
@formatter = formatter_create(conf: formatter_config)
|
34
39
|
@has_buffer_section = conf.elements(name: 'buffer').size > 0
|
40
|
+
if !@monitor.nil?
|
41
|
+
@send_time_formatter = time_formatter_create(
|
42
|
+
type: @monitor.time_type.to_sym, format: @monitor.time_format
|
43
|
+
)
|
44
|
+
end
|
35
45
|
end
|
36
46
|
|
37
47
|
def rewrite_tag(tag)
|
@@ -72,9 +82,9 @@ module Fluent::Plugin
|
|
72
82
|
end
|
73
83
|
|
74
84
|
def add_send_time(record)
|
75
|
-
if @send_time
|
85
|
+
if !@monitor.nil? && @monitor.send_time
|
76
86
|
# send_time is recorded in ms
|
77
|
-
record.merge({"#{@send_time_key}": Fluent::EventTime.now})
|
87
|
+
record.merge({"#{@monitor.send_time_key}": @send_time_formatter.format(Fluent::EventTime.now)})
|
78
88
|
else
|
79
89
|
record
|
80
90
|
end
|
@@ -84,7 +94,7 @@ module Fluent::Plugin
|
|
84
94
|
if es.class == Fluent::OneEventStream
|
85
95
|
es = inject_values_to_event_stream(tag, es)
|
86
96
|
es.each do |time, record|
|
87
|
-
log.debug "#{rewrite_tag(tag)}, #{time}, #{add_send_time(record)}"
|
97
|
+
log.debug "MqttOutput#publish_event_stream: #{rewrite_tag(tag)}, #{time}, #{add_send_time(record)}"
|
88
98
|
rescue_disconnection do
|
89
99
|
@client.publish(rewrite_tag(tag), @formatter.format(tag, time, add_send_time(record)))
|
90
100
|
end
|
@@ -93,7 +103,7 @@ module Fluent::Plugin
|
|
93
103
|
es = inject_values_to_event_stream(tag, es)
|
94
104
|
array = []
|
95
105
|
es.each do |time, record|
|
96
|
-
log.debug "#{rewrite_tag(tag)}, #{time}, #{add_send_time(record)}"
|
106
|
+
log.debug "MqttOutput#publish_event_stream: #{rewrite_tag(tag)}, #{time}, #{add_send_time(record)}"
|
97
107
|
array << add_send_time(record)
|
98
108
|
end
|
99
109
|
rescue_disconnection do
|
@@ -120,7 +130,7 @@ module Fluent::Plugin
|
|
120
130
|
return if chunk.empty?
|
121
131
|
chunk.each do |tag, time, record|
|
122
132
|
rescue_disconnection do
|
123
|
-
log.debug "#{rewrite_tag(rewrite_tag(tag))}, #{time}, #{add_send_time(record)}"
|
133
|
+
log.debug "MqttOutput#write: #{rewrite_tag(rewrite_tag(tag))}, #{time}, #{add_send_time(record)}"
|
124
134
|
@client.publish(rewrite_tag(tag), @formatter.format(tag, time, add_send_time(record)))
|
125
135
|
end
|
126
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mqtt-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toyokazu Akiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: []
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|