logstash-output-newrelic 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 750803d3594bfcf428aa32102cdb23679ae0f91a2efa5dc970e7520b8550fdaa
4
- data.tar.gz: 101d475ad8adabc356c8041f8ef97481f20aba9041aac4df78e003b524e79196
3
+ metadata.gz: 998bef6edbc8fb754b22ab4cca0f25b3e27182e3ac22b5992840ebeab1086764
4
+ data.tar.gz: 9d2517ffcc0b573a5c2321dea3c4ca8ced58df4563346f93a1925983169c1a6d
5
5
  SHA512:
6
- metadata.gz: 8b770681904d2286b9cdb63231af2e1dffe6f438308796d4b1171916d39ebd98c4f3b702f924305fab7ec4d8965da6ee1f9c444e012bb20e42e5f057d8076dff
7
- data.tar.gz: cab594f0010916cbbaf54403df7d3f431a5999fdac6418ca52ee7730b4981e55700658d5275fcd33055f296ba310e63f32610ab9f1636d6ab1ecea95f239345a
6
+ metadata.gz: 5ebeed8b92b33be3ff45d7148ff402d0128fb0a29fa8028380a046b32819ea5c76ee2d388386ebc801a0840371ccc991a2253c7cf5806d8bc9a0cf050420f0d6
7
+ data.tar.gz: '02922a85561259f830f3c142dbabac0bb59867e8bf1b87c2fc0810304c51f0d9333251768e32715014c0d1c60bc071ad0b5f0f142bf5dbab54677b0dc9fea477'
data/DEVELOPER.md CHANGED
@@ -15,11 +15,11 @@
15
15
  * Build the gem: `jruby -S gem build logstash-output-newrelic.gemspec`
16
16
 
17
17
  ## Pushing changes to the public repo
18
- After updating the New Relic repo with changes, changes will need to be pushed to the public GitHub repo at: https://github.com/newrelic/newrelic-fluent-bit-output
18
+ After updating the New Relic repo with changes, changes will need to be pushed to the public GitHub repo at: https://github.com/newrelic/logstash-output-plugin
19
19
 
20
- * `git remote add public git@github.com:newrelic/newrelic-fluent-bit-output.git`
20
+ * `git remote add public git@github.com:newrelic/logstash-output-plugin.git`
21
21
  * `git push public master:name-of-branch-to-create`
22
- * Create a PR from that branch in https://github.com/newrelic/newrelic-fluent-bit-output
22
+ * Create a PR from that branch in https://github.com/newrelic/logstash-output-plugin
23
23
  * Get the PR reviewed, merged, and delete the branch!
24
24
 
25
25
  # Testing it with a local Logstash install
@@ -20,8 +20,6 @@ class LogStash::Outputs::NewRelic < LogStash::Outputs::Base
20
20
  config :concurrent_requests, :validate => :number, :default => 1
21
21
  config :base_uri, :validate => :string, :default => "https://log-api.newrelic.com/log/v1"
22
22
 
23
- # TODO: do we need to define "concurrency"? https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_output_plugin.html
24
-
25
23
  public
26
24
 
27
25
  def register
@@ -41,10 +39,27 @@ class LogStash::Outputs::NewRelic < LogStash::Outputs::Base
41
39
  end
42
40
 
43
41
  def encode(event_hash)
42
+ log_message_hash = {
43
+ 'attributes' => {}
44
+ }
44
45
 
45
- event_hash.delete('@timestamp')
46
- event_hash = maybe_parse_message_json(event_hash)
47
- event_hash
46
+ if event_hash.has_key?('message')
47
+ log_message_hash['attributes'] = maybe_parse_json(event_hash['message'])
48
+ end
49
+
50
+ event_hash.each do |key, value|
51
+ if key == 'message' || key == 'timestamp'
52
+ # intrinsic attributes go at the top level
53
+ log_message_hash[key] = value
54
+ elsif key == '@timestamp'
55
+ # Do not add @timestamp
56
+ else
57
+ # non-intrinsic attributes get put into 'attributes'
58
+ log_message_hash['attributes'][key] = value
59
+ end
60
+ end
61
+
62
+ log_message_hash
48
63
  end
49
64
 
50
65
  def maybe_parse_message_json(event_hash)
@@ -1,7 +1,7 @@
1
1
  module LogStash
2
2
  module Outputs
3
3
  module NewRelicVersion
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -83,8 +83,6 @@ describe LogStash::Outputs::NewRelic do
83
83
  wait_for(a_request(:post, base_uri)
84
84
  .with { |request|
85
85
  data = multiple_gzipped_messages(request.body)[0]
86
- data.keys[0] == 'common' &&
87
- data.keys[1] == 'logs' &&
88
86
  data['common']['attributes']['plugin']['type'] == 'logstash' &&
89
87
  data['common']['attributes']['plugin']['version'] == LogStash::Outputs::NewRelicVersion::VERSION })
90
88
  .to have_been_made
@@ -111,8 +109,9 @@ describe LogStash::Outputs::NewRelic do
111
109
  wait_for(a_request(:post, base_uri)
112
110
  .with { |request|
113
111
  message = single_gzipped_message(request.body)
112
+ puts message
114
113
  message['message'] == 'Test message' &&
115
- message['other'] == 'Other value' })
114
+ message['attributes']['other'] == 'Other value' })
116
115
  .to have_been_made
117
116
  end
118
117
 
@@ -126,10 +125,10 @@ describe LogStash::Outputs::NewRelic do
126
125
  wait_for(a_request(:post, base_uri)
127
126
  .with { |request|
128
127
  message = single_gzipped_message(request.body)
129
- message['in-json-1'] == '1' &&
130
- message['in-json-2'] == '2' &&
131
- message['sub-object'] == {"in-json-3" => "3"} &&
132
- message['other'] == 'Other value' })
128
+ message['attributes']['in-json-1'] == '1' &&
129
+ message['attributes']['in-json-2'] == '2' &&
130
+ message['attributes']['sub-object'] == {"in-json-3" => "3"} &&
131
+ message['attributes']['other'] == 'Other value' })
133
132
  .to have_been_made
134
133
  end
135
134
 
@@ -144,7 +143,7 @@ describe LogStash::Outputs::NewRelic do
144
143
  .with { |request|
145
144
  message = single_gzipped_message(request.body)
146
145
  message['message'] == message_json_array &&
147
- message['other'] == 'Other value' })
146
+ message['attributes']['other'] == 'Other value' })
148
147
  .to have_been_made
149
148
  end
150
149
 
@@ -159,7 +158,7 @@ describe LogStash::Outputs::NewRelic do
159
158
  .with { |request|
160
159
  message = single_gzipped_message(request.body)
161
160
  message['message'] == message_json_string &&
162
- message['other'] == 'Other value' })
161
+ message['attributes']['other'] == 'Other value' })
163
162
  .to have_been_made
164
163
  end
165
164
 
@@ -174,7 +173,7 @@ describe LogStash::Outputs::NewRelic do
174
173
  .with { |request|
175
174
  message = single_gzipped_message(request.body)
176
175
  message['message'] == 'Test message' &&
177
- message['other'] == other_json })
176
+ message['attributes']['other'] == other_json })
178
177
  .to have_been_made
179
178
  end
180
179
 
@@ -187,7 +186,7 @@ describe LogStash::Outputs::NewRelic do
187
186
  wait_for(a_request(:post, base_uri)
188
187
  .with { |request|
189
188
  message = single_gzipped_message(request.body)
190
- message['other'] == 'Other value' })
189
+ message['attributes']['other'] == 'Other value' })
191
190
  .to have_been_made
192
191
  end
193
192
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - New Relic Logging Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-26 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement