fluent-plugin-sumologic_output 0.0.0 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/README.md +7 -54
- data/fluent-plugin-sumologic_output.gemspec +7 -9
- data/lib/fluent/plugin/out_sumologic.rb +44 -157
- metadata +9 -61
- data/.travis.yml +0 -11
- data/CHANGELOG.md +0 -85
- data/Gemfile +0 -9
- data/Rakefile +0 -11
- data/ci/build.sh +0 -17
- data/test/helper.rb +0 -16
- data/test/plugin/test_out_sumologic.rb +0 -330
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c8c3c7a728a21e36723ac49f6a23c5eca312c84
|
4
|
+
data.tar.gz: f1f96116cbd38bc8819ab3f036cbd24adbc82bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a600c768ebd50ea0f4cc1408ab043cfe0a82051cb5b12c23d936157cc7d2e8fa207869a0a1fc3631a775ffb721699473190ab71635bfd21c1c6a60d5a046e62
|
7
|
+
data.tar.gz: ee118235d86fad65d50a376805472dea0cd57bbd05bf252d9c647a9160d4f43aab9c707c130c952afc65dd556a52783dd111939bdea570f742bc8b77f1c7a227
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,47 +1,30 @@
|
|
1
|
-
|
1
|
+
# fluent-plugin-sumologic_out, a plugin for [Fluentd](http://fluentd.org)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
This plugin has been designed to output logs or metrics to [SumoLogic](http://www.sumologic.com) via a [HTTP collector endpoint](http://help.sumologic.com/Send_Data/Sources/02Sources_for_Hosted_Collectors/HTTP_Source)
|
6
|
-
|
7
|
-
## Support
|
8
|
-
The code in this repository has been developed in collaboration with the Sumo Logic community and is not supported via standard Sumo Logic Support channels. For any issues or questions please submit an issue within the GitHub repository. The maintainers of this project will work directly with the community to answer any questions, address bugs, or review any requests for new features.
|
9
|
-
|
10
|
-
## License
|
11
|
-
Released under Apache 2.0 License.
|
3
|
+
This plugin has been designed to output logs to [SumoLogic](http://www.sumologic.com) via a [HTTP collector endpoint](http://help.sumologic.com/Send_Data/Sources/02Sources_for_Hosted_Collectors/HTTP_Source)
|
12
4
|
|
13
5
|
## Installation
|
14
6
|
|
15
|
-
gem install fluent-plugin-
|
7
|
+
gem install fluent-plugin-sumologic_out
|
16
8
|
|
17
9
|
## Configuration
|
18
10
|
|
19
11
|
Configuration options for fluent.conf are:
|
20
12
|
|
21
|
-
* `data_type` - The type of data that will be sent to Sumo Logic, either `logs` or `metrics` (Default is `logs `)
|
22
13
|
* `endpoint` - SumoLogic HTTP Collector URL
|
23
14
|
* `verify_ssl` - Verify ssl certificate. (default is `true`)
|
24
15
|
* `source_category` - Set _sourceCategory metadata field within SumoLogic (default is `nil`)
|
25
|
-
* `source_name` - Set _sourceName metadata field within SumoLogic
|
26
|
-
* `source_name_key` - Set as source::path_key's value so that the source_name can be extracted from Fluentd's buffer (default `source_name`)
|
16
|
+
* `source_name` - Set _sourceName metadata field within SumoLogic (default is `nil`)
|
27
17
|
* `source_host` - Set _sourceHost metadata field within SumoLogic (default is `nil`)
|
28
18
|
* `log_format` - Format to post logs into Sumo. (default `json`)
|
29
19
|
* text - Logs will appear in SumoLogic in text format (taken from the field specified in `log_key`)
|
30
20
|
* json - Logs will appear in SumoLogic in json format.
|
31
21
|
* json_merge - Same as json but merge content of `log_key` into the top level and strip `log_key`
|
32
22
|
* `log_key` - Used to specify the key when merging json or sending logs in text format (default `message`)
|
33
|
-
|
34
|
-
* `add_timestamp` - Add `timestamp` (or `timestamp_key`) field to logs before sending to sumologic (default `true`)
|
35
|
-
* `timestamp_key` - Field name when `add_timestamp` is on (default `timestamp`)
|
36
|
-
* `proxy_uri` - Add the `uri` of the `proxy` environment if present.
|
37
|
-
* `metric_data_format` - The format of metrics you will be sending, either `graphite` or `carbon2` or `prometheus` (Default is `graphite `)
|
38
|
-
* `disable_cookies` - Option to disable cookies on the HTTP Client. (Default is `false `)
|
39
|
-
|
40
|
-
### Example Configuration
|
23
|
+
|
41
24
|
Reading from the JSON formatted log files with `in_tail` and wildcard filenames:
|
42
25
|
```
|
43
26
|
<source>
|
44
|
-
|
27
|
+
type tail
|
45
28
|
format json
|
46
29
|
time_key time
|
47
30
|
path /path/to/*.log
|
@@ -52,37 +35,11 @@ Reading from the JSON formatted log files with `in_tail` and wildcard filenames:
|
|
52
35
|
</source>
|
53
36
|
|
54
37
|
<match appa.**>
|
55
|
-
|
38
|
+
type sumologic
|
56
39
|
endpoint https://collectors.sumologic.com/receiver/v1/http/XXXXXXXXXX
|
57
40
|
log_format json
|
58
41
|
source_category prod/someapp/logs
|
59
42
|
source_name AppA
|
60
|
-
open_timeout 10
|
61
|
-
</match>
|
62
|
-
```
|
63
|
-
|
64
|
-
Sending metrics to Sumo Logic using `in_http`:
|
65
|
-
```
|
66
|
-
<source>
|
67
|
-
@type http
|
68
|
-
port 8888
|
69
|
-
bind 0.0.0.0
|
70
|
-
</source>
|
71
|
-
|
72
|
-
<match test.carbon2>
|
73
|
-
@type sumologic
|
74
|
-
endpoint https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/ZaVnC4dhaV1hYfCAiqSH-PDY6gUOIgZvO60U_-y8SPQfK0Ks-ht7owrbk1AkX_ACp0uUxuLZOCw5QjBg1ndVPZ5TOJCFgNGRtFDoTDuQ2hzs3sn6FlfBSw==
|
75
|
-
data_type metrics
|
76
|
-
metric_data_format carbon2
|
77
|
-
flush_interval 1s
|
78
|
-
</match>
|
79
|
-
|
80
|
-
<match test.graphite>
|
81
|
-
@type sumologic
|
82
|
-
endpoint https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/ZaVnC4dhaV1hYfCAiqSH-PDY6gUOIgZvO60U_-y8SPQfK0Ks-ht7owrbk1AkX_ACp0uUxuLZOCw5QjBg1ndVPZ5TOJCFgNGRtFDoTDuQ2hzs3sn6FlfBSw==
|
83
|
-
data_type metrics
|
84
|
-
metric_data_format graphite
|
85
|
-
flush_interval 1s
|
86
43
|
</match>
|
87
44
|
```
|
88
45
|
|
@@ -132,7 +89,3 @@ Example
|
|
132
89
|
"levelname": "INFO"
|
133
90
|
}
|
134
91
|
```
|
135
|
-
|
136
|
-
### TLS 1.2 Requirement
|
137
|
-
|
138
|
-
Sumo Logic only accepts connections from clients using TLS version 1.2 or greater. To utilize the content of this repo, ensure that it's running in an execution environment that is configured to use TLS 1.2 or greater.
|
@@ -4,9 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "fluent-plugin-sumologic_output"
|
7
|
-
gem.version = "0.0.
|
8
|
-
gem.authors = ["Steven Adams"
|
9
|
-
gem.email = ["stevezau@gmail.com"
|
7
|
+
gem.version = "0.0.3"
|
8
|
+
gem.authors = ["Steven Adams"]
|
9
|
+
gem.email = ["stevezau@gmail.com"]
|
10
10
|
gem.description = %q{Output plugin to SumoLogic HTTP Endpoint}
|
11
11
|
gem.summary = %q{Output plugin to SumoLogic HTTP Endpoint}
|
12
12
|
gem.homepage = "https://github.com/SumoLogic/fluentd-output-sumologic"
|
@@ -16,13 +16,11 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
+
gem.has_rdoc = false
|
19
20
|
|
20
21
|
gem.required_ruby_version = '>= 2.0.0'
|
21
22
|
|
22
|
-
gem.add_development_dependency "bundler", "~>
|
23
|
+
gem.add_development_dependency "bundler", "~> 1.3"
|
23
24
|
gem.add_development_dependency "rake"
|
24
|
-
gem.
|
25
|
-
|
26
|
-
gem.add_runtime_dependency "fluentd", ">= 0.14.12"
|
27
|
-
gem.add_runtime_dependency 'httpclient', '~> 2.8.0'
|
28
|
-
end
|
25
|
+
gem.add_runtime_dependency "fluentd"
|
26
|
+
end
|
@@ -1,132 +1,60 @@
|
|
1
|
-
require 'fluent/
|
1
|
+
require 'fluent/output'
|
2
2
|
require 'net/https'
|
3
3
|
require 'yajl'
|
4
|
-
require 'httpclient'
|
5
4
|
|
6
5
|
class SumologicConnection
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(endpoint, verify_ssl, connect_timeout, proxy_uri, disable_cookies)
|
11
|
-
@endpoint = endpoint
|
12
|
-
create_http_client(verify_ssl, connect_timeout, proxy_uri, disable_cookies)
|
13
|
-
end
|
14
|
-
|
15
|
-
def publish(raw_data, source_host=nil, source_category=nil, source_name=nil, data_type, metric_data_type)
|
16
|
-
response = http.post(@endpoint, raw_data, request_headers(source_host, source_category, source_name, data_type, metric_data_type))
|
17
|
-
unless response.ok?
|
18
|
-
raise RuntimeError, "Failed to send data to HTTP Source. #{response.code} - #{response.body}"
|
19
|
-
end
|
6
|
+
def initialize(endpoint, verify_ssl)
|
7
|
+
@endpoint_uri = URI.parse(endpoint.strip)
|
8
|
+
@verify_ssl = verify_ssl
|
20
9
|
end
|
21
10
|
|
22
|
-
def
|
23
|
-
|
24
|
-
'X-Sumo-Name' => source_name,
|
25
|
-
'X-Sumo-Category' => source_category,
|
26
|
-
'X-Sumo-Host' => source_host,
|
27
|
-
'X-Sumo-Client' => 'fluentd-output'
|
28
|
-
}
|
29
|
-
if data_type == 'metrics'
|
30
|
-
case metric_data_format
|
31
|
-
when 'graphite'
|
32
|
-
headers['Content-Type'] = 'application/vnd.sumologic.graphite'
|
33
|
-
when 'carbon2'
|
34
|
-
headers['Content-Type'] = 'application/vnd.sumologic.carbon2'
|
35
|
-
when 'prometheus'
|
36
|
-
headers['Content-Type'] = 'application/vnd.sumologic.prometheus'
|
37
|
-
else
|
38
|
-
raise RuntimeError, "Invalid #{metric_data_format}, must be graphite or carbon2 or prometheus"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
return headers
|
11
|
+
def publish(raw_data, source_host=nil, source_category=nil, source_name=nil)
|
12
|
+
http.request(request_for(raw_data, source_host, source_category, source_name))
|
42
13
|
end
|
43
14
|
|
44
|
-
|
45
|
-
|
15
|
+
private
|
16
|
+
def request_for(raw_data, source_host, source_category, source_name)
|
17
|
+
request = Net::HTTP::Post.new(@endpoint_uri.request_uri)
|
18
|
+
request.body = raw_data
|
19
|
+
request['X-Sumo-Name'] = source_name
|
20
|
+
request['X-Sumo-Category'] = source_category
|
21
|
+
request['X-Sumo-Host'] = source_host
|
22
|
+
request
|
46
23
|
end
|
47
24
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
25
|
+
def http
|
26
|
+
# Rubys HTTP is not thread safe, so we need a new instance for each request
|
27
|
+
client = Net::HTTP.new(@endpoint_uri.host, @endpoint_uri.port)
|
28
|
+
client.use_ssl = true
|
29
|
+
client.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
30
|
+
client
|
55
31
|
end
|
56
32
|
end
|
57
33
|
|
58
|
-
class
|
34
|
+
class Sumologic < Fluent::BufferedOutput
|
59
35
|
# First, register the plugin. NAME is the name of this plugin
|
60
36
|
# and identifies the plugin in the configuration file.
|
61
37
|
Fluent::Plugin.register_output('sumologic', self)
|
62
38
|
|
63
|
-
|
64
|
-
DEFAULT_BUFFER_TYPE = "memory"
|
65
|
-
LOGS_DATA_TYPE = "logs"
|
66
|
-
METRICS_DATA_TYPE = "metrics"
|
67
|
-
DEFAULT_DATA_TYPE = LOGS_DATA_TYPE
|
68
|
-
DEFAULT_METRIC_FORMAT_TYPE = 'graphite'
|
69
|
-
|
70
|
-
config_param :data_type, :string, :default => DEFAULT_DATA_TYPE
|
71
|
-
config_param :metric_data_format, :default => DEFAULT_METRIC_FORMAT_TYPE
|
72
|
-
config_param :endpoint, :string, secret: true
|
39
|
+
config_param :endpoint, :string
|
73
40
|
config_param :log_format, :string, :default => 'json'
|
74
41
|
config_param :log_key, :string, :default => 'message'
|
75
42
|
config_param :source_category, :string, :default => nil
|
76
43
|
config_param :source_name, :string, :default => nil
|
77
|
-
config_param :source_name_key, :string, :default => 'source_name'
|
78
44
|
config_param :source_host, :string, :default => nil
|
79
45
|
config_param :verify_ssl, :bool, :default => true
|
80
|
-
config_param :delimiter, :string, :default => "."
|
81
|
-
config_param :open_timeout, :integer, :default => 60
|
82
|
-
config_param :add_timestamp, :bool, :default => true
|
83
|
-
config_param :timestamp_key, :string, :default => 'timestamp'
|
84
|
-
config_param :proxy_uri, :string, :default => nil
|
85
|
-
config_param :disable_cookies, :bool, :default => false
|
86
|
-
|
87
|
-
config_section :buffer do
|
88
|
-
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
89
|
-
config_set_default :chunk_keys, ['tag']
|
90
|
-
end
|
91
|
-
|
92
|
-
def initialize
|
93
|
-
super
|
94
|
-
end
|
95
|
-
|
96
|
-
def multi_workers_ready?
|
97
|
-
true
|
98
|
-
end
|
99
46
|
|
100
47
|
# This method is called before starting.
|
101
48
|
def configure(conf)
|
102
|
-
|
103
|
-
compat_parameters_convert(conf, :buffer)
|
104
|
-
|
105
49
|
unless conf['endpoint'] =~ URI::regexp
|
106
50
|
raise Fluent::ConfigError, "Invalid SumoLogic endpoint url: #{conf['endpoint']}"
|
107
51
|
end
|
108
52
|
|
109
|
-
unless conf['
|
110
|
-
|
111
|
-
raise Fluent::ConfigError, "Invalid data_type #{conf['data_type']} must be logs or metrics"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
if conf['data_type'].nil? || conf['data_type'] == LOGS_DATA_TYPE
|
116
|
-
unless conf['log_format'].nil?
|
117
|
-
unless conf['log_format'] =~ /\A(?:json|text|json_merge)\z/
|
118
|
-
raise Fluent::ConfigError, "Invalid log_format #{conf['log_format']} must be text, json or json_merge"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
if conf['data_type'] == METRICS_DATA_TYPE && ! conf['metrics_data_type'].nil?
|
124
|
-
unless conf['metrics_data_type'] =~ /\A(?:graphite|carbon2|pronetheus)\z/
|
125
|
-
raise Fluent::ConfigError, "Invalid metrics_data_type #{conf['metrics_data_type']} must be graphite or carbon2 or prometheus"
|
126
|
-
end
|
53
|
+
unless conf['log_format'] =~ /\A(?:json|text|json_merge)\z/
|
54
|
+
raise Fluent::ConfigError, "Invalid log_format #{conf['log_format']} must be text, json or json_merge"
|
127
55
|
end
|
128
56
|
|
129
|
-
@sumo_conn = SumologicConnection.new(conf['endpoint'],
|
57
|
+
@sumo_conn = SumologicConnection.new(conf['endpoint'], @verify_ssl)
|
130
58
|
super
|
131
59
|
end
|
132
60
|
|
@@ -146,7 +74,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
|
|
146
74
|
log = record[@log_key].strip
|
147
75
|
if log[0].eql?('{') && log[-1].eql?('}')
|
148
76
|
begin
|
149
|
-
record =
|
77
|
+
record = JSON.parse(log).merge(record)
|
150
78
|
record.delete(@log_key)
|
151
79
|
rescue JSON::ParserError
|
152
80
|
# do nothing, ignore
|
@@ -159,39 +87,17 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
|
|
159
87
|
# Strip sumo_metadata and dump to json
|
160
88
|
def dump_log(log)
|
161
89
|
log.delete('_sumo_metadata')
|
162
|
-
|
163
|
-
parser = Yajl::Parser.new
|
164
|
-
hash = parser.parse(log[@log_key])
|
165
|
-
log[@log_key] = hash
|
166
|
-
Yajl.dump(log)
|
167
|
-
rescue
|
168
|
-
Yajl.dump(log)
|
169
|
-
end
|
90
|
+
Yajl.dump(log)
|
170
91
|
end
|
171
92
|
|
172
93
|
def format(tag, time, record)
|
173
|
-
|
174
|
-
mstime = time * 1000 + (time.nsec / 1000000)
|
175
|
-
[mstime, record].to_msgpack
|
176
|
-
else
|
177
|
-
[time, record].to_msgpack
|
178
|
-
end
|
94
|
+
[tag, time, record].to_msgpack
|
179
95
|
end
|
180
96
|
|
181
|
-
def
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
def sumo_key(sumo_metadata, chunk)
|
186
|
-
source_name = sumo_metadata['source'] || @source_name
|
187
|
-
source_name = extract_placeholders(source_name, chunk) unless source_name.nil?
|
188
|
-
|
189
|
-
source_category = sumo_metadata['category'] || @source_category
|
190
|
-
source_category = extract_placeholders(source_category, chunk) unless source_category.nil?
|
191
|
-
|
192
|
-
source_host = sumo_metadata['host'] || @source_host
|
193
|
-
source_host = extract_placeholders(source_host, chunk) unless source_host.nil?
|
194
|
-
|
97
|
+
def sumo_key(sumo)
|
98
|
+
source_name = sumo['source'] || @source_name
|
99
|
+
source_category = sumo['category'] || @source_category
|
100
|
+
source_host = sumo['host'] || @source_host
|
195
101
|
"#{source_name}:#{source_category}:#{source_host}"
|
196
102
|
end
|
197
103
|
|
@@ -205,41 +111,24 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
|
|
205
111
|
messages_list = {}
|
206
112
|
|
207
113
|
# Sort messages
|
208
|
-
chunk.msgpack_each do |time, record|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
sumo_metadata = record.fetch('_sumo_metadata', {:source => record[@source_name_key] })
|
213
|
-
key = sumo_key(sumo_metadata, chunk)
|
214
|
-
log_format = sumo_metadata['log_format'] || @log_format
|
114
|
+
chunk.msgpack_each do |tag, time, record|
|
115
|
+
sumo_metadata = record.fetch('_sumo_metadata', {})
|
116
|
+
key = sumo_key(sumo_metadata)
|
117
|
+
log_format = sumo_metadata['log_format'] || @log_format
|
215
118
|
|
216
119
|
# Strip any unwanted newlines
|
217
|
-
record[@log_key].chomp! if record[@log_key]
|
120
|
+
record[@log_key].chomp! if record[@log_key]
|
218
121
|
|
219
|
-
case
|
220
|
-
when 'logs'
|
221
|
-
case log_format
|
122
|
+
case log_format
|
222
123
|
when 'text'
|
223
124
|
log = record[@log_key]
|
224
125
|
unless log.nil?
|
225
126
|
log.strip!
|
226
127
|
end
|
227
128
|
when 'json_merge'
|
228
|
-
|
229
|
-
record = { @timestamp_key => sumo_timestamp(time) }.merge(record)
|
230
|
-
end
|
231
|
-
log = dump_log(merge_json(record))
|
129
|
+
log = dump_log(merge_json({:timestamp => sumo_timestamp(time)}.merge(record)))
|
232
130
|
else
|
233
|
-
|
234
|
-
record = { @timestamp_key => sumo_timestamp(time) }.merge(record)
|
235
|
-
end
|
236
|
-
log = dump_log(record)
|
237
|
-
end
|
238
|
-
when 'metrics'
|
239
|
-
log = record[@log_key]
|
240
|
-
unless log.nil?
|
241
|
-
log.strip!
|
242
|
-
end
|
131
|
+
log = dump_log({:timestamp => sumo_timestamp(time)}.merge(record))
|
243
132
|
end
|
244
133
|
|
245
134
|
unless log.nil?
|
@@ -257,13 +146,11 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
|
|
257
146
|
source_name, source_category, source_host = key.split(':')
|
258
147
|
@sumo_conn.publish(
|
259
148
|
messages.join("\n"),
|
260
|
-
source_host
|
261
|
-
source_category
|
262
|
-
source_name
|
263
|
-
data_type =@data_type,
|
264
|
-
metric_data_format =@metric_data_format
|
149
|
+
source_host=source_host,
|
150
|
+
source_category=source_category,
|
151
|
+
source_name=source_name
|
265
152
|
)
|
266
153
|
end
|
267
154
|
|
268
155
|
end
|
269
|
-
end
|
156
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-sumologic_output
|
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
|
- Steven Adams
|
8
|
-
- Frank Reno
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-12-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
@@ -17,14 +16,14 @@ dependencies:
|
|
17
16
|
requirements:
|
18
17
|
- - "~>"
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
19
|
+
version: '1.3'
|
21
20
|
type: :development
|
22
21
|
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
24
|
- - "~>"
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
26
|
+
version: '1.3'
|
28
27
|
- !ruby/object:Gem::Dependency
|
29
28
|
name: rake
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,82 +38,32 @@ dependencies:
|
|
39
38
|
- - ">="
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '0'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: test-unit
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 3.1.0
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 3.1.0
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: codecov
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.1.10
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.1.10
|
70
41
|
- !ruby/object:Gem::Dependency
|
71
42
|
name: fluentd
|
72
43
|
requirement: !ruby/object:Gem::Requirement
|
73
44
|
requirements:
|
74
45
|
- - ">="
|
75
46
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
47
|
+
version: '0'
|
77
48
|
type: :runtime
|
78
49
|
prerelease: false
|
79
50
|
version_requirements: !ruby/object:Gem::Requirement
|
80
51
|
requirements:
|
81
52
|
- - ">="
|
82
53
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: httpclient
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - "~>"
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 2.8.0
|
91
|
-
type: :runtime
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: 2.8.0
|
54
|
+
version: '0'
|
98
55
|
description: Output plugin to SumoLogic HTTP Endpoint
|
99
56
|
email:
|
100
57
|
- stevezau@gmail.com
|
101
|
-
- frank.reno@me.com
|
102
58
|
executables: []
|
103
59
|
extensions: []
|
104
60
|
extra_rdoc_files: []
|
105
61
|
files:
|
106
62
|
- ".gitignore"
|
107
|
-
- ".travis.yml"
|
108
|
-
- CHANGELOG.md
|
109
|
-
- Gemfile
|
110
63
|
- LICENSE
|
111
64
|
- README.md
|
112
|
-
- Rakefile
|
113
|
-
- ci/build.sh
|
114
65
|
- fluent-plugin-sumologic_output.gemspec
|
115
66
|
- lib/fluent/plugin/out_sumologic.rb
|
116
|
-
- test/helper.rb
|
117
|
-
- test/plugin/test_out_sumologic.rb
|
118
67
|
homepage: https://github.com/SumoLogic/fluentd-output-sumologic
|
119
68
|
licenses:
|
120
69
|
- Apache-2.0
|
@@ -134,10 +83,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
83
|
- !ruby/object:Gem::Version
|
135
84
|
version: '0'
|
136
85
|
requirements: []
|
137
|
-
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.5.1
|
138
88
|
signing_key:
|
139
89
|
specification_version: 4
|
140
90
|
summary: Output plugin to SumoLogic HTTP Endpoint
|
141
|
-
test_files:
|
142
|
-
- test/helper.rb
|
143
|
-
- test/plugin/test_out_sumologic.rb
|
91
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
lang: ruby
|
2
|
-
before_install: gem install bundler
|
3
|
-
script: ci/build.sh
|
4
|
-
deploy:
|
5
|
-
provider: rubygems
|
6
|
-
api_key:
|
7
|
-
secure: mzu7CaM8x5BLZ2QvgQJFfY/xvzZN2+gpMieRoBnmefjhhs+zGjqzBn9wN+4/IZNQUKhDE729CEx1xSEegz44Ru73sNEsS4Y/jLNqr24Swcr4xyYcqxX58x18o1K28HD1Mp9NhS8gLIkd/sucCcSAHPag6Zkk00gETGsGCXFHxYP5HpXbBMKy1OFZ3o7dGv+Hv4g5XtDaM1Kjwcku398PsQsBmh0jJyag+NL804dUL66weTA3P7q94/TEVZ1lbvUZlokzxHBhkO0eHM2fuCdKzW1BneePxYnMRFzjRxXcYoalfEVoy9KHi3mDBCtj4Bw6hSgfnrDFVjZzoMPybOLJDt9DlYEplcWlXlS3EuDr5aYgyfkUbuv1OZm/94EdkMa4epH51vq0r6AHstG7ZCmrBxiLUMs0wgwRSPTIK1hJG+UFuCxGASU+IH8OD8bTav21cXEhVLDw5dEzk6smnfY+mpAexiW5ytIc9wf0qkP6bbICH9zRHYUWHxcCTqouhArHPyyESSngAYkpdHbRql+uGll8ab6IaVp33WvKqYQK2QnTcb1A7pgtiAxzhl0yBTR/oNIRdj6X6y7FmRuaEmkU29jzuetcq4xdgQTkNfbeLITwyRn2hJBGHIEcvHPwilzZGIfr96QcqBw/AGrcIirkD3NuZ86DJZ8Ucn3BbKXEmTU=
|
8
|
-
gem: fluent-plugin-sumologic_output
|
9
|
-
on:
|
10
|
-
tags: true
|
11
|
-
repo: SumoLogic/fluentd-output-sumologic
|
data/CHANGELOG.md
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
# Change Log
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file. Tracking did not begin until version 1.10.
|
4
|
-
|
5
|
-
<a name="1.4.0"></a>
|
6
|
-
# [1.4.0] (2019-01-16)
|
7
|
-
|
8
|
-
* [Add timestamp_key, prefer log message when merging](https://github.com/SumoLogic/fluentd-output-sumologic/pull/37)
|
9
|
-
|
10
|
-
<a name="1.3.2"></a>
|
11
|
-
# [1.3.2] (2018-12-05)
|
12
|
-
|
13
|
-
* Fix verify SSL bug
|
14
|
-
|
15
|
-
<a name="1.3.1"></a>
|
16
|
-
# [1.3.1] (2018-08-30)
|
17
|
-
|
18
|
-
* [Sumo Logic endpoint is a secret](https://github.com/SumoLogic/fluentd-output-sumologic/pull/32)
|
19
|
-
|
20
|
-
<a name="1.3.0"></a>
|
21
|
-
# [1.3.0] (2018-08-08)
|
22
|
-
|
23
|
-
<a name="1.2.0"></a>
|
24
|
-
# [1.2.0] (2018-07-18)
|
25
|
-
|
26
|
-
* add support for multi worker
|
27
|
-
|
28
|
-
<a name="1.1.1"></a>
|
29
|
-
# [1.1.1] (2018-07-12)
|
30
|
-
|
31
|
-
* if `record[@log_key]` is json, parse it as JSON and not as string.
|
32
|
-
|
33
|
-
<a name="1.1.0"></a>
|
34
|
-
# [1.1.0] (2018-06-29)
|
35
|
-
|
36
|
-
* Add support for sending metrics.
|
37
|
-
|
38
|
-
<a name="1.0.3"></a>
|
39
|
-
# [1.0.3] (2018-05-07)
|
40
|
-
|
41
|
-
* [Fix #26 -- Don't chomp if the message is not chomp-able](https://github.com/SumoLogic/fluentd-output-sumologic/pull/29)
|
42
|
-
|
43
|
-
<a name="1.0.2"></a>
|
44
|
-
# [1.0.2] (2018-04-09)
|
45
|
-
|
46
|
-
* [add option to turn off adding timestamp to logs](https://github.com/SumoLogic/fluentd-output-sumologic/pull/27)
|
47
|
-
|
48
|
-
<a name="1.0.1"></a>
|
49
|
-
# [1.0.1] (2017-12-19)
|
50
|
-
|
51
|
-
* [Add client header for fluentd output](https://github.com/SumoLogic/fluentd-output-sumologic/pull/22)
|
52
|
-
|
53
|
-
<a name="1.0.0"></a>
|
54
|
-
# [1.0.0] (2017-11-06)
|
55
|
-
|
56
|
-
* [Upgrade to 0.14 API, send with ms precision](https://github.com/SumoLogic/fluentd-output-sumologic/pull/12)
|
57
|
-
* [Switch to httpclient](https://github.com/SumoLogic/fluentd-output-sumologic/pull/16)
|
58
|
-
* [Fix missing variable and improve config example](https://github.com/SumoLogic/fluentd-output-sumologic/pull/17)
|
59
|
-
|
60
|
-
<a name="0.0.7"></a>
|
61
|
-
# [0.0.7] (2017-10-26)
|
62
|
-
|
63
|
-
* [Expand parameters in the output configuration](https://github.com/SumoLogic/fluentd-output-sumologic/pull/14)
|
64
|
-
* [add open_timeout option](https://github.com/SumoLogic/fluentd-output-sumologic/pull/15)
|
65
|
-
|
66
|
-
<a name="0.0.6"></a>
|
67
|
-
# [0.0.6] (2017-08-23)
|
68
|
-
|
69
|
-
* Fix 0.0.5
|
70
|
-
|
71
|
-
<a name="0.0.5"></a>
|
72
|
-
# [0.0.5] (2017-08-18)
|
73
|
-
|
74
|
-
* [Ignore garbage records. Fix inspired by other plugins](https://github.com/SumoLogic/fluentd-output-sumologic/pull/7)
|
75
|
-
* [Extract the source_name from FluentD's buffer](https://github.com/SumoLogic/fluentd-output-sumologic/pull/8)
|
76
|
-
|
77
|
-
<a name="0.0.4"></a>
|
78
|
-
# [0.0.4] (2017-07-05)
|
79
|
-
|
80
|
-
* [Raise an exception for all non HTTP Success response codes](https://github.com/SumoLogic/fluentd-output-sumologic/pull/5)
|
81
|
-
|
82
|
-
<a name="0.0.3"></a>
|
83
|
-
# [0.0.3] (2016-12-10)
|
84
|
-
|
85
|
-
* Initial Release
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/ci/build.sh
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
echo "Starting build process in: `pwd`"
|
4
|
-
set -e
|
5
|
-
|
6
|
-
if [! -z "${TRAVIS_TAG}" ]; then
|
7
|
-
echo "Building for tag ${TRAVIS_TAG}, modify .gemspec file..."
|
8
|
-
sed -i '' "s/0.0.0/${TRAVIS_TAG}/g" ./fluent-plugin-sumologic_output.gemspec
|
9
|
-
fi
|
10
|
-
|
11
|
-
echo "Install bundler..."
|
12
|
-
bundle install
|
13
|
-
|
14
|
-
echo "Run unit tests..."
|
15
|
-
bundle exec rake
|
16
|
-
|
17
|
-
echo "DONE"
|
data/test/helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start
|
3
|
-
|
4
|
-
if ENV['CI'] == 'true'
|
5
|
-
require 'codecov'
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
7
|
-
end
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
10
|
-
require "test-unit"
|
11
|
-
require "fluent/test"
|
12
|
-
require "fluent/test/driver/output"
|
13
|
-
require "fluent/test/helpers"
|
14
|
-
|
15
|
-
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
16
|
-
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
@@ -1,330 +0,0 @@
|
|
1
|
-
require "test-unit"
|
2
|
-
require "fluent/test"
|
3
|
-
require "fluent/test/driver/output"
|
4
|
-
require "fluent/test/helpers"
|
5
|
-
require 'webmock/test_unit'
|
6
|
-
require 'fluent/plugin/out_sumologic'
|
7
|
-
|
8
|
-
class SumologicOutput < Test::Unit::TestCase
|
9
|
-
include Fluent::Test::Helpers
|
10
|
-
|
11
|
-
def setup
|
12
|
-
Fluent::Test.setup
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_driver(conf = CONFIG)
|
16
|
-
Fluent::Test::Driver::Output.new(Fluent::Plugin::Sumologic).configure(conf)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_no_endpoint_configure
|
20
|
-
config = %{}
|
21
|
-
exception = assert_raise(Fluent::ConfigError) {create_driver(config)}
|
22
|
-
assert_equal("Invalid SumoLogic endpoint url: ", exception.message)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_invalid_data_type_configure
|
26
|
-
config = %{
|
27
|
-
endpoint https://SUMOLOGIC_URL
|
28
|
-
data_type 'foo'
|
29
|
-
}
|
30
|
-
exception = assert_raise(Fluent::ConfigError) {create_driver(config)}
|
31
|
-
assert_equal("Invalid data_type foo must be logs or metrics", exception.message)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_invalid_log_format_configure
|
35
|
-
config = %{
|
36
|
-
endpoint https://SUMOLOGIC_URL
|
37
|
-
log_format foo
|
38
|
-
}
|
39
|
-
exception = assert_raise(Fluent::ConfigError) {create_driver(config)}
|
40
|
-
assert_equal("Invalid log_format foo must be text, json or json_merge", exception.message)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_invalid_metrics_data_type
|
44
|
-
config = %{
|
45
|
-
endpoint https://SUMOLOGIC_URL
|
46
|
-
data_type metrics
|
47
|
-
metrics_data_type foo
|
48
|
-
}
|
49
|
-
exception = assert_raise(Fluent::ConfigError) {create_driver(config)}
|
50
|
-
assert_equal("Invalid metrics_data_type foo must be graphite or carbon2 or prometheus", exception.message)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_default_configure
|
54
|
-
config = %{
|
55
|
-
endpoint https://SUMOLOGIC_URL
|
56
|
-
}
|
57
|
-
instance = create_driver(config).instance
|
58
|
-
|
59
|
-
assert_equal instance.data_type, 'logs'
|
60
|
-
assert_equal instance.metric_data_format, 'graphite'
|
61
|
-
assert_equal instance.endpoint, 'https://SUMOLOGIC_URL'
|
62
|
-
assert_equal instance.log_format, 'json'
|
63
|
-
assert_equal instance.log_key, 'message'
|
64
|
-
assert_equal instance.source_category, nil
|
65
|
-
assert_equal instance.source_name, nil
|
66
|
-
assert_equal instance.source_name_key, 'source_name'
|
67
|
-
assert_equal instance.source_host, nil
|
68
|
-
assert_equal instance.verify_ssl, true
|
69
|
-
assert_equal instance.delimiter, '.'
|
70
|
-
assert_equal instance.open_timeout, 60
|
71
|
-
assert_equal instance.add_timestamp, true
|
72
|
-
assert_equal instance.timestamp_key, 'timestamp'
|
73
|
-
assert_equal instance.proxy_uri, nil
|
74
|
-
assert_equal instance.disable_cookies, false
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_emit_text
|
78
|
-
config = %{
|
79
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
80
|
-
log_format text
|
81
|
-
source_category test
|
82
|
-
source_host test
|
83
|
-
source_name test
|
84
|
-
|
85
|
-
}
|
86
|
-
driver = create_driver(config)
|
87
|
-
time = event_time
|
88
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
89
|
-
driver.run do
|
90
|
-
driver.feed("output.test", time, {'foo' => 'bar', 'message' => 'test'})
|
91
|
-
end
|
92
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
93
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
94
|
-
body: "test",
|
95
|
-
times:1
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_emit_json
|
99
|
-
config = %{
|
100
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
101
|
-
log_format json
|
102
|
-
source_category test
|
103
|
-
source_host test
|
104
|
-
source_name test
|
105
|
-
|
106
|
-
}
|
107
|
-
driver = create_driver(config)
|
108
|
-
time = event_time
|
109
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
110
|
-
driver.run do
|
111
|
-
driver.feed("output.test", time, {'foo' => 'bar', 'message' => 'test'})
|
112
|
-
end
|
113
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
114
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
115
|
-
body: /\A{"timestamp":\d+.,"foo":"bar","message":"test"}\z/,
|
116
|
-
times:1
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_emit_json_double_encoded
|
120
|
-
config = %{
|
121
|
-
endpoint https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/1234
|
122
|
-
log_format json
|
123
|
-
source_category test
|
124
|
-
source_host test
|
125
|
-
source_name test
|
126
|
-
|
127
|
-
}
|
128
|
-
driver = create_driver(config)
|
129
|
-
time = event_time
|
130
|
-
stub_request(:post, 'https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/1234')
|
131
|
-
driver.run do
|
132
|
-
driver.feed("output.test", time, {'message' => '{"bar":"foo"}'})
|
133
|
-
end
|
134
|
-
assert_requested :post, "https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/1234",
|
135
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
136
|
-
body: /\A{"timestamp":\d+.,"message":{"bar":"foo"}}\z/,
|
137
|
-
times:1
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_emit_text_format_as_json
|
141
|
-
config = %{
|
142
|
-
endpoint https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/1234
|
143
|
-
log_format json
|
144
|
-
source_category test
|
145
|
-
source_host test
|
146
|
-
source_name test
|
147
|
-
|
148
|
-
}
|
149
|
-
driver = create_driver(config)
|
150
|
-
time = event_time
|
151
|
-
stub_request(:post, 'https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/1234')
|
152
|
-
driver.run do
|
153
|
-
driver.feed("output.test", time, {'message' => 'some message'})
|
154
|
-
end
|
155
|
-
assert_requested :post, "https://endpoint3.collection.us2.sumologic.com/receiver/v1/http/1234",
|
156
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
157
|
-
body: /\A{"timestamp":\d+.,"message":"some message"}\z/,
|
158
|
-
times:1
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_emit_json_merge
|
162
|
-
config = %{
|
163
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
164
|
-
log_format json_merge
|
165
|
-
source_category test
|
166
|
-
source_host test
|
167
|
-
source_name test
|
168
|
-
|
169
|
-
}
|
170
|
-
driver = create_driver(config)
|
171
|
-
time = event_time
|
172
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
173
|
-
driver.run do
|
174
|
-
driver.feed("output.test", time, {'foo' => 'bar', 'message' => '{"foo2":"bar2"}'})
|
175
|
-
end
|
176
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
177
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
178
|
-
body: /\A{"timestamp":\d+,"foo":"bar","foo2":"bar2"}\z/,
|
179
|
-
times:1
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_emit_json_merge_timestamp
|
183
|
-
config = %{
|
184
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
185
|
-
log_format json_merge
|
186
|
-
source_category test
|
187
|
-
source_host test
|
188
|
-
source_name test
|
189
|
-
|
190
|
-
}
|
191
|
-
driver = create_driver(config)
|
192
|
-
time = event_time
|
193
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
194
|
-
driver.run do
|
195
|
-
driver.feed("output.test", time, {'message' => '{"timestamp":123}'})
|
196
|
-
end
|
197
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
198
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
199
|
-
body: /\A{"timestamp":123}\z/,
|
200
|
-
times:1
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_emit_with_sumo_metadata
|
204
|
-
config = %{
|
205
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
206
|
-
log_format json
|
207
|
-
}
|
208
|
-
driver = create_driver(config)
|
209
|
-
time = event_time
|
210
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
211
|
-
ENV['HOST'] = "foo"
|
212
|
-
driver.run do
|
213
|
-
driver.feed("output.test", time, {'foo' => 'bar', 'message' => 'test', '_sumo_metadata' => {
|
214
|
-
"host": "#{ENV['HOST']}",
|
215
|
-
"source": "${tag}",
|
216
|
-
"category": "${tag[1]}"
|
217
|
-
}})
|
218
|
-
end
|
219
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
220
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'foo', 'X-Sumo-Name'=>'output.test'},
|
221
|
-
body: /\A{"timestamp":\d+.,"foo":"bar","message":"test"}\z/,
|
222
|
-
times:1
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_emit_json_no_timestamp
|
226
|
-
config = %{
|
227
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
228
|
-
log_format json
|
229
|
-
source_category test
|
230
|
-
source_host test
|
231
|
-
source_name test
|
232
|
-
add_timestamp false
|
233
|
-
}
|
234
|
-
driver = create_driver(config)
|
235
|
-
time = event_time
|
236
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
237
|
-
driver.run do
|
238
|
-
driver.feed("output.test", time, {'foo' => 'bar', 'message' => 'test'})
|
239
|
-
end
|
240
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
241
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
242
|
-
body: /\A{"foo":"bar","message":"test"}\z/,
|
243
|
-
times:1
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_emit_json_timestamp_key
|
247
|
-
config = %{
|
248
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
249
|
-
log_format json
|
250
|
-
source_category test
|
251
|
-
source_host test
|
252
|
-
source_name test
|
253
|
-
timestamp_key ts
|
254
|
-
}
|
255
|
-
driver = create_driver(config)
|
256
|
-
time = event_time
|
257
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
258
|
-
driver.run do
|
259
|
-
driver.feed("output.test", time, {'message' => 'test'})
|
260
|
-
end
|
261
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
262
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
|
263
|
-
body: /\A{"ts":\d+.,"message":"test"}\z/,
|
264
|
-
times:1
|
265
|
-
end
|
266
|
-
|
267
|
-
def test_emit_graphite
|
268
|
-
config = %{
|
269
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
270
|
-
data_type metrics
|
271
|
-
metric_data_format graphite
|
272
|
-
source_category test
|
273
|
-
source_host test
|
274
|
-
source_name test
|
275
|
-
}
|
276
|
-
driver = create_driver(config)
|
277
|
-
time = event_time
|
278
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
279
|
-
driver.run do
|
280
|
-
driver.feed("output.test", time, {'message' =>'prod.lb-1.cpu 87.2 1501753030'})
|
281
|
-
end
|
282
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
283
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'Content-Type'=>'application/vnd.sumologic.graphite'},
|
284
|
-
body: /\Aprod.lb-1.cpu 87.2 1501753030\z/,
|
285
|
-
times:1
|
286
|
-
end
|
287
|
-
|
288
|
-
def test_emit_carbon
|
289
|
-
config = %{
|
290
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
291
|
-
data_type metrics
|
292
|
-
metric_data_format carbon2
|
293
|
-
source_category test
|
294
|
-
source_host test
|
295
|
-
source_name test
|
296
|
-
}
|
297
|
-
driver = create_driver(config)
|
298
|
-
time = event_time
|
299
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
300
|
-
driver.run do
|
301
|
-
driver.feed("output.test", time, {'message' =>'cluster=prod node=lb-1 metric=cpu ip=2.2.3.4 team=infra 87.2 1501753030'})
|
302
|
-
end
|
303
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
304
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'Content-Type'=>'application/vnd.sumologic.carbon2'},
|
305
|
-
body: /\Acluster=prod node=lb-1 metric=cpu ip=2.2.3.4 team=infra 87.2 1501753030\z/,
|
306
|
-
times:1
|
307
|
-
end
|
308
|
-
|
309
|
-
def test_emit_prometheus
|
310
|
-
config = %{
|
311
|
-
endpoint https://collectors.sumologic.com/v1/receivers/http/1234
|
312
|
-
data_type metrics
|
313
|
-
metric_data_format prometheus
|
314
|
-
source_category test
|
315
|
-
source_host test
|
316
|
-
source_name test
|
317
|
-
}
|
318
|
-
driver = create_driver(config)
|
319
|
-
time = event_time
|
320
|
-
stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
|
321
|
-
driver.run do
|
322
|
-
driver.feed("output.test", time, {'message' =>'cpu{cluster="prod", node="lb-1"} 87.2 1501753030'})
|
323
|
-
end
|
324
|
-
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
|
325
|
-
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'Content-Type'=>'application/vnd.sumologic.prometheus'},
|
326
|
-
body: 'cpu{cluster="prod", node="lb-1"} 87.2 1501753030',
|
327
|
-
times:1
|
328
|
-
end
|
329
|
-
|
330
|
-
end
|