fluent-plugin-sumologic_output 1.4.0 → 1.4.1

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
- SHA1:
3
- metadata.gz: 129fc1c24fc6e1ac2b446b80fdfc7ac5165b7986
4
- data.tar.gz: b9f01bee4b86185e306c7155c228a54cde730145
2
+ SHA256:
3
+ metadata.gz: 4346ff078527905ff2b54424eef12afbbb88b37174fdca0e7b36cb6addadf2a7
4
+ data.tar.gz: 83bfd102b85451d7f4ec5d6635482efbdd945fe8ef2e52d14bfd56ca1b48cb18
5
5
  SHA512:
6
- metadata.gz: e64e61a98fd1a39122b11661cdd3dd03507a0f5968700f69042604ff26ff0eb34d4d8095b46390fbc30d758570314b8b346b105a3affb9c4b63164b50a0ee953
7
- data.tar.gz: 1b41b319196744540f98839e5f6d04d670fbfa492b31d6594868c76e193bf075f7c78eb180494b5e69bf1306bb174f8ab78f34cbd24ff841f681e33c12206063
6
+ metadata.gz: 6ac64815e9d60e5ecd9af2fb867e28822185b12d368ed0a3566bdfc0f0a958dc77d2ae5bef11cefba13306f4691a5b72e892c28b9a7e8282fb4193c645799d43
7
+ data.tar.gz: 27623a54343eab0c96f7c1e8577176cc6deccffcd65d34af7d9411b0334051d365bfe6ea9e7bae34462163282cc84af86bded65300130ff908a0b47d86c9f63a
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  Gemfile.lock
4
- .idea/
4
+ .idea/
5
+ TAGS
data/.travis.yml CHANGED
@@ -1,5 +1,12 @@
1
1
  lang: ruby
2
-
3
- script: bundle exec rake
4
-
5
- rvm: 2.3
2
+ before_install: gem install bundler
3
+ script: ci/build.sh
4
+ deploy:
5
+ provider: rubygems
6
+ skip_cleanup: true
7
+ api_key:
8
+ secure: mzu7CaM8x5BLZ2QvgQJFfY/xvzZN2+gpMieRoBnmefjhhs+zGjqzBn9wN+4/IZNQUKhDE729CEx1xSEegz44Ru73sNEsS4Y/jLNqr24Swcr4xyYcqxX58x18o1K28HD1Mp9NhS8gLIkd/sucCcSAHPag6Zkk00gETGsGCXFHxYP5HpXbBMKy1OFZ3o7dGv+Hv4g5XtDaM1Kjwcku398PsQsBmh0jJyag+NL804dUL66weTA3P7q94/TEVZ1lbvUZlokzxHBhkO0eHM2fuCdKzW1BneePxYnMRFzjRxXcYoalfEVoy9KHi3mDBCtj4Bw6hSgfnrDFVjZzoMPybOLJDt9DlYEplcWlXlS3EuDr5aYgyfkUbuv1OZm/94EdkMa4epH51vq0r6AHstG7ZCmrBxiLUMs0wgwRSPTIK1hJG+UFuCxGASU+IH8OD8bTav21cXEhVLDw5dEzk6smnfY+mpAexiW5ytIc9wf0qkP6bbICH9zRHYUWHxcCTqouhArHPyyESSngAYkpdHbRql+uGll8ab6IaVp33WvKqYQK2QnTcb1A7pgtiAxzhl0yBTR/oNIRdj6X6y7FmRuaEmkU29jzuetcq4xdgQTkNfbeLITwyRn2hJBGHIEcvHPwilzZGIfr96QcqBw/AGrcIirkD3NuZ86DJZ8Ucn3BbKXEmTU=
9
+ gem: fluent-plugin-sumologic_output
10
+ on:
11
+ tags: true
12
+ repo: SumoLogic/fluentd-output-sumologic
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/SumoLogic/fluentd-output-sumologic.svg?branch=master)](https://travis-ci.org/SumoLogic/fluentd-output-sumologic) ![](https://ruby-gem-downloads-badge.herokuapp.com/fluent-plugin-sumologic_output?type=total) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/SumoLogic/fluentd-output-sumologic/issues)
1
+ [![Build Status](https://travis-ci.org/SumoLogic/fluentd-output-sumologic.svg?branch=master)](https://travis-ci.org/SumoLogic/fluentd-output-sumologic) [![Gem Version](https://badge.fury.io/rb/fluent-plugin-sumologic_output.svg)](https://badge.fury.io/rb/fluent-plugin-sumologic_output) ![](https://ruby-gem-downloads-badge.herokuapp.com/fluent-plugin-sumologic_output?type=total) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/SumoLogic/fluentd-output-sumologic/issues)
2
2
 
3
3
  # fluent-plugin-sumologic_output, a plugin for [Fluentd](http://fluentd.org)
4
4
 
@@ -34,7 +34,7 @@ Configuration options for fluent.conf are:
34
34
  * `add_timestamp` - Add `timestamp` (or `timestamp_key`) field to logs before sending to sumologic (default `true`)
35
35
  * `timestamp_key` - Field name when `add_timestamp` is on (default `timestamp`)
36
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` (Default is `graphite `)
37
+ * `metric_data_format` - The format of metrics you will be sending, either `graphite` or `carbon2` or `prometheus` (Default is `graphite `)
38
38
  * `disable_cookies` - Option to disable cookies on the HTTP Client. (Default is `false `)
39
39
 
40
40
  ### Example Configuration
data/ci/build.sh ADDED
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+
3
+ echo "Starting build process in: `pwd`"
4
+ set -e
5
+
6
+ VERSION="${TRAVIS_TAG:=0.0.0}"
7
+ echo "Building for tag $VERSION, modify .gemspec file..."
8
+ sed -i.bak "s/0.0.0/$VERSION/g" ./fluent-plugin-sumologic_output.gemspec
9
+ rm -f ./fluent-plugin-sumologic_output.gemspec.bak
10
+
11
+ echo "Install bundler..."
12
+ bundle install
13
+
14
+ echo "Run unit tests..."
15
+ bundle exec rake
16
+
17
+ echo "DONE"
@@ -4,7 +4,7 @@ $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 = "1.4.0"
7
+ gem.version = "1.4.1"
8
8
  gem.authors = ["Steven Adams", "Frank Reno"]
9
9
  gem.email = ["stevezau@gmail.com", "frank.reno@me.com"]
10
10
  gem.description = %q{Output plugin to SumoLogic HTTP Endpoint}
@@ -16,7 +16,6 @@ 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
20
19
 
21
20
  gem.required_ruby_version = '>= 2.0.0'
22
21
 
@@ -32,8 +32,10 @@ class SumologicConnection
32
32
  headers['Content-Type'] = 'application/vnd.sumologic.graphite'
33
33
  when 'carbon2'
34
34
  headers['Content-Type'] = 'application/vnd.sumologic.carbon2'
35
+ when 'prometheus'
36
+ headers['Content-Type'] = 'application/vnd.sumologic.prometheus'
35
37
  else
36
- raise RuntimeError, "Invalid #{metric_data_format}, must be graphite or carbon2"
38
+ raise RuntimeError, "Invalid #{metric_data_format}, must be graphite or carbon2 or prometheus"
37
39
  end
38
40
  end
39
41
  return headers
@@ -63,9 +65,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
63
65
  LOGS_DATA_TYPE = "logs"
64
66
  METRICS_DATA_TYPE = "metrics"
65
67
  DEFAULT_DATA_TYPE = LOGS_DATA_TYPE
66
- GRAPHITE_METRIC_FORMAT_TYPE = "graphite"
67
- CARBON2_METRIC_FORMAT_TYPE = "carbon2"
68
- DEFAULT_METRIC_FORMAT_TYPE = CARBON2_METRIC_FORMAT_TYPE
68
+ DEFAULT_METRIC_FORMAT_TYPE = 'graphite'
69
69
 
70
70
  config_param :data_type, :string, :default => DEFAULT_DATA_TYPE
71
71
  config_param :metric_data_format, :default => DEFAULT_METRIC_FORMAT_TYPE
@@ -121,8 +121,8 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
121
121
  end
122
122
 
123
123
  if conf['data_type'] == METRICS_DATA_TYPE && ! conf['metrics_data_type'].nil?
124
- unless conf['metrics_data_type'] =~ /\A(?:graphite|carbon2)\z/
125
- raise Fluent::ConfigError, "Invalid metrics_data_type #{conf['metrics_data_type']} must be graphite or carbon2"
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
126
  end
127
127
  end
128
128
 
@@ -182,15 +182,15 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
182
182
  true
183
183
  end
184
184
 
185
- def sumo_key(sumo_metadata, record, tag)
185
+ def sumo_key(sumo_metadata, chunk)
186
186
  source_name = sumo_metadata['source'] || @source_name
187
- source_name = expand_param(source_name, tag, nil, record)
187
+ source_name = extract_placeholders(source_name, chunk) unless source_name.nil?
188
188
 
189
189
  source_category = sumo_metadata['category'] || @source_category
190
- source_category = expand_param(source_category, tag, nil, record)
190
+ source_category = extract_placeholders(source_category, chunk) unless source_category.nil?
191
191
 
192
192
  source_host = sumo_metadata['host'] || @source_host
193
- source_host = expand_param(source_host, tag, nil, record)
193
+ source_host = extract_placeholders(source_host, chunk) unless source_host.nil?
194
194
 
195
195
  "#{source_name}:#{source_category}:#{source_host}"
196
196
  end
@@ -200,38 +200,8 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
200
200
  time.to_s.length == 13 ? time : time * 1000
201
201
  end
202
202
 
203
- # copy from https://github.com/uken/fluent-plugin-elasticsearch/commit/1722c58758b4da82f596ecb0a5075d3cb6c99b2e#diff-33bfa932bf1443760673c69df745272eR221
204
- def expand_param(param, tag, time, record)
205
- # check for '${ ... }'
206
- # yes => `eval`
207
- # no => return param
208
- return param if (param =~ /\${.+}/).nil?
209
-
210
- # check for 'tag_parts[]'
211
- # separated by a delimiter (default '.')
212
- tag_parts = tag.split(@delimiter) unless (param =~ /tag_parts\[.+\]/).nil? || tag.nil?
213
-
214
- # pull out section between ${} then eval
215
- inner = param.clone
216
- while inner.match(/\${.+}/)
217
- to_eval = inner.match(/\${(.+?)}/) { $1 }
218
-
219
- if !(to_eval =~ /record\[.+\]/).nil? && record.nil?
220
- return to_eval
221
- elsif !(to_eval =~/tag_parts\[.+\]/).nil? && tag_parts.nil?
222
- return to_eval
223
- elsif !(to_eval =~/time/).nil? && time.nil?
224
- return to_eval
225
- else
226
- inner.sub!(/\${.+?}/, eval(to_eval))
227
- end
228
- end
229
- inner
230
- end
231
-
232
203
  # This method is called every flush interval. Write the buffer chunk
233
204
  def write(chunk)
234
- tag = chunk.metadata.tag
235
205
  messages_list = {}
236
206
 
237
207
  # Sort messages
@@ -240,7 +210,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
240
210
  # https://github.com/uken/fluent-plugin-elasticsearch/commit/8597b5d1faf34dd1f1523bfec45852d380b26601#diff-ae62a005780cc730c558e3e4f47cc544R94
241
211
  next unless record.is_a? Hash
242
212
  sumo_metadata = record.fetch('_sumo_metadata', {:source => record[@source_name_key] })
243
- key = sumo_key(sumo_metadata, record, tag)
213
+ key = sumo_key(sumo_metadata, chunk)
244
214
  log_format = sumo_metadata['log_format'] || @log_format
245
215
 
246
216
  # Strip any unwanted newlines
@@ -47,7 +47,7 @@ class SumologicOutput < Test::Unit::TestCase
47
47
  metrics_data_type foo
48
48
  }
49
49
  exception = assert_raise(Fluent::ConfigError) {create_driver(config)}
50
- assert_equal("Invalid metrics_data_type foo must be graphite or carbon2", exception.message)
50
+ assert_equal("Invalid metrics_data_type foo must be graphite or carbon2 or prometheus", exception.message)
51
51
  end
52
52
 
53
53
  def test_default_configure
@@ -57,7 +57,7 @@ class SumologicOutput < Test::Unit::TestCase
57
57
  instance = create_driver(config).instance
58
58
 
59
59
  assert_equal instance.data_type, 'logs'
60
- assert_equal instance.metric_data_format, 'carbon2'
60
+ assert_equal instance.metric_data_format, 'graphite'
61
61
  assert_equal instance.endpoint, 'https://SUMOLOGIC_URL'
62
62
  assert_equal instance.log_format, 'json'
63
63
  assert_equal instance.log_key, 'message'
@@ -213,7 +213,7 @@ class SumologicOutput < Test::Unit::TestCase
213
213
  driver.feed("output.test", time, {'foo' => 'bar', 'message' => 'test', '_sumo_metadata' => {
214
214
  "host": "#{ENV['HOST']}",
215
215
  "source": "${tag}",
216
- "category": "test"
216
+ "category": "${tag[1]}"
217
217
  }})
218
218
  end
219
219
  assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
@@ -306,4 +306,25 @@ class SumologicOutput < Test::Unit::TestCase
306
306
  times:1
307
307
  end
308
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
+
309
330
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sumologic_output
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Adams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-17 00:00:00.000000000 Z
12
+ date: 2019-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -110,6 +110,7 @@ files:
110
110
  - LICENSE
111
111
  - README.md
112
112
  - Rakefile
113
+ - ci/build.sh
113
114
  - fluent-plugin-sumologic_output.gemspec
114
115
  - lib/fluent/plugin/out_sumologic.rb
115
116
  - test/helper.rb
@@ -133,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  - !ruby/object:Gem::Version
134
135
  version: '0'
135
136
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.6.11
137
+ rubygems_version: 3.0.3
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Output plugin to SumoLogic HTTP Endpoint