fluent-plugin-newrelic 1.0.1 → 1.1.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
2
  SHA256:
3
- metadata.gz: cd81b1178e9c16c6d1a9814e456b13936132c96a70c32248f7da5947255875e0
4
- data.tar.gz: ebc969b9fbb9bc02f8053e7e039f9d748dba44ab7c29fc4d4b9d96dba378a19d
3
+ metadata.gz: 6dbed0d5014d5685b57429081cbdc0dc5198f0ecccfe0dc523571efa6ea50ad5
4
+ data.tar.gz: f98c59dca5ccdb35c0c3cf0032864177da7ae34342b9e2471d68f6b54a7f6bbf
5
5
  SHA512:
6
- metadata.gz: '0498345d651300e2e75bf44fe0c183fc6b861d29688125aa97d1129a1ae4f1798a1bcac00bd29278e163f7c3d46771fa547ee14768bad0e6f3a39ecc0f9fe23d'
7
- data.tar.gz: 8d9830136f2bd34c54820a07ab86bfc7fb40150357501e1ad4854bf037e206fbacee8aff7401cddcd451b3fdcf809ff0fb690dac5d91e43e5d2d7f71fa002c24
6
+ metadata.gz: 88d7afb9aabd9ab5552bc48fe3aaa06f6dced0dc62e7178c5abefb4bd36e9cd147b9395a582da1f7eec864c5991ca44eb4fc55391db35d447d3e11aa36cd2ad0
7
+ data.tar.gz: efcdfef5a81b079e4badf992a6976874142e951ef70e26a872a86b01392f2cbca913ac8ed6117d3519d3d8d078e000d27465e6ddd72846654112bf1799a803c1
@@ -25,7 +25,6 @@ td-agent is unloaded. Super weird, but now you know.
25
25
  <match **>
26
26
  @type newrelic
27
27
  api_key (your-api-key)
28
- base_uri https://staging-insights-collector.newrelic.com/logs/v1
29
28
  </match>
30
29
 
31
30
  <source>
@@ -43,15 +42,16 @@ td-agent is unloaded. Super weird, but now you know.
43
42
  * Start Fluentd: `sudo launchctl load /Library/LaunchDaemons/td-agent.plist`
44
43
  * Make sure things start up OK: `tail -f /var/log/td-agent/td-agent.log`
45
44
  * Cause a change that you've configured Fluentd to pick up: (`echo "FluentdTest" >> /usr/local/var/log/test.log`
46
- * Look in `https://staging-one.newrelic.com/launcher/logger.log-launcher` for your log message ("FluentdTest")
45
+ * Look in `https://one.newrelic.com/launcher/logger.log-launcher` for your log message ("FluentdTest")
47
46
 
48
47
  ## Pushing changes to the public repo
48
+
49
49
  After updating the New Relic repo with changes, changes will need to be pushed to the public GitHub repo
50
50
  at: https://github.com/newrelic/newrelic-fluentd-output
51
51
 
52
52
  Make sure you have the public set up as a remote called `public`:
53
53
  ```
54
- git remote add public git@github.com:newrelic/logstash-output-plugin.git
54
+ git remote add public git@github.com:newrelic/newrelic-fluentd-output.git
55
55
  ```
56
56
 
57
57
  Sync:
data/README.md CHANGED
@@ -31,12 +31,12 @@ For more info, review [Fluentd's official documentation](https://docs.fluentd.or
31
31
 
32
32
  | Property | Description | Default value |
33
33
  |---|---|---|
34
- | concurrent_requests | The number of threads to make requests from | 1 |
35
- | retries | The maximum number of times to retry a failed request, exponentially increasing delay between each retry | 5 |
36
- | retry_seconds | The initial delay between retries, in seconds | 5 |
37
- | max_delay | The maximum delay between retries, in seconds | 30 |
38
34
  | base_uri | New Relic ingestion endpoint | 'https://log-api.newrelic.com/log/v1' |
39
35
 
36
+ ### EU plugin configuration
37
+
38
+ If you are running this plugin in the eu set the `base_uri` to `http://log-api.eu.newrelic.com/log/v1`.
39
+
40
40
  ### Fields
41
41
 
42
42
  * To make Kubernetes log forwarding easier, any `log` field in a log event will be
@@ -27,12 +27,9 @@ module Fluent
27
27
  Fluent::Plugin.register_output('newrelic', self)
28
28
  helpers :thread
29
29
 
30
- config_param :api_key, :string
30
+ config_param :api_key, :string, :default => nil
31
31
  config_param :base_uri, :string, :default => "https://log-api.newrelic.com/log/v1"
32
- config_param :retry_seconds, :integer, :default => 5
33
- config_param :max_delay, :integer, :default => 30
34
- config_param :retries, :integer, :default => 5
35
- config_param :concurrent_requests, :integer, :default => 1
32
+ config_param :license_key, :string, :default => nil
36
33
 
37
34
  DEFAULT_BUFFER_TYPE = 'memory'.freeze
38
35
 
@@ -51,14 +48,21 @@ module Fluent
51
48
 
52
49
  def configure(conf)
53
50
  super
51
+ if @api_key.nil? && @license_key.nil?
52
+ raise Fluent::ConfigError.new("'api_key' or `license_key` parameter is required")
53
+ end
54
54
 
55
55
  # create initial sockets hash and socket based on config param
56
56
  @end_point = URI.parse(@base_uri)
57
+ auth = {
58
+ @api_key.nil? ? 'X-License_key' : 'X-Insert-Key' =>
59
+ @api_key.nil? ? @license_key : @api_key
60
+ }
57
61
  @header = {
58
- 'X-Insert-Key' => @api_key,
59
62
  'X-Event-Source' => 'logs',
60
63
  'Content-Encoding' => 'gzip'
61
- }.freeze
64
+ }.merge(auth)
65
+ .freeze
62
66
  end
63
67
 
64
68
  def package_record(record, timestamp)
@@ -106,35 +110,13 @@ module Fluent
106
110
  gzip = Zlib::GzipWriter.new(io)
107
111
  gzip << [payload].to_json
108
112
  gzip.close
109
- attempt_send(io.string, 0)
110
- end
111
-
112
- def should_retry?(attempt)
113
- attempt < @retries
113
+ send(io.string)
114
114
  end
115
-
116
- def was_successful?(response)
117
- 200 <= response.code.to_i && response.code.to_i < 300
118
- end
119
-
120
- def sleep_duration(attempt)
121
- if attempt == 0
122
- return 0
115
+
116
+ def handle_response(response)
117
+ if !(200 <= response.code.to_i && response.code.to_i < 300)
118
+ log.error("Response was " + response.code + " " + response.body)
123
119
  end
124
-
125
- [@max_delay, (2 ** (attempt - 1)) * @retry_seconds].min
126
- end
127
-
128
- def sleep_on_retry(attempt)
129
- duration = sleep_duration(attempt)
130
- if duration > 0
131
- sleep duration
132
- end
133
- end
134
-
135
- def attempt_send(payload, attempt)
136
- sleep_on_retry(attempt)
137
- attempt_send(payload, attempt + 1) unless was_successful?(send(payload)) if should_retry?(attempt)
138
120
  end
139
121
 
140
122
  def send(payload)
@@ -143,7 +125,7 @@ module Fluent
143
125
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
144
126
  request = Net::HTTP::Post.new(@end_point.request_uri, @header)
145
127
  request.body = payload
146
- http.request(request)
128
+ handle_response(http.request(request))
147
129
  end
148
130
 
149
131
  end
@@ -1,3 +1,3 @@
1
1
  module NewrelicFluentdOutput
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - New Relic Logging Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-29 00:00:00.000000000 Z
11
+ date: 2019-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd