logstash-output-timber 1.0.1 → 1.0.2

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: 876397ec04113baadf58af67a3f152ed8b03c3290984e519b98fda3a3d153e64
4
- data.tar.gz: a2faf8c5c07eb1cbdae00b572c77b486e386d164d9f9300bd85b34d3af6edefc
3
+ metadata.gz: 41db80ea8dc6e0c7655f0fcc3c84101be85c8241de366ef07493dedea222b67d
4
+ data.tar.gz: 1c0c6e41505a4a1b4b090663d29480aee491eceb58dce58c9af5e0c47418817d
5
5
  SHA512:
6
- metadata.gz: 8353f74f4f7d3802be35d728975bec9085a7704e0978d30efb2841a61f5f4a23d573581b3e19753c001ddbe74ce8c98b9a43e840560a098aa6256d6de4b073b2
7
- data.tar.gz: aa31ab11e03084c657de88e951180a7e5354748e7424bb996c5055ac65aed888fa53850bdee136bf6d30a3b17dea80a53fcf0c7a5c8e7d4fa0c6e236dd52aab5
6
+ metadata.gz: 49fb12cb9a25669e2d270ce7b315222f9a5a5988aa51c826dfc85821ed6b116bff18dcf1740e49c3acf03e910b897bd31cd6b2d62f645d5a1be65f7006d2b3a5
7
+ data.tar.gz: 58c94bb43555676e76e7d11bedf0df71277c2f47f6832cfa6ec5b2e7610a15270750d7fec0672a6a661bd5cd0f87fb2a6bf33142d626e504ad66cdf430878b5b
@@ -13,7 +13,7 @@ require "logstash/outputs/timber/http_client"
13
13
  class LogStash::Outputs::Timber < LogStash::Outputs::Base
14
14
  include HttpClient
15
15
 
16
- VERSION = "1.0.1".freeze
16
+ VERSION = "1.0.2".freeze
17
17
  CONTENT_TYPE = "application/json".freeze
18
18
  MAX_ATTEMPTS = 3
19
19
  METHOD = :post.freeze
@@ -130,6 +130,8 @@ class LogStash::Outputs::Timber < LogStash::Outputs::Base
130
130
  def event_hash(e)
131
131
  hash = e.to_hash
132
132
  hash.delete("@version")
133
+ dt = hash.delete("@timestamp")
134
+ hash["dt"] = dt if !hash.has_key?("dt")
133
135
  hash
134
136
  end
135
137
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-timber'
3
- s.version = "1.0.1"
3
+ s.version = "1.0.2"
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "This output send events to the Timber.io logging service"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -113,6 +113,22 @@ describe LogStash::Outputs::Timber do
113
113
  expect(requests.length).to eq(3)
114
114
  end
115
115
 
116
+ it "handles fatal request errors" do
117
+ allow(output.send(:http_client)).to receive(:post).and_raise("boom")
118
+
119
+ output.url = "http://localhost:#{port}/good"
120
+ result = output.send(:send_events, [event], 1)
121
+ expect(result).to eq(false)
122
+ end
123
+
124
+ it "handles retryable request errors" do
125
+ expect(output.send(:http_client)).to receive(:post).exactly(3).times.and_raise(::Manticore::Timeout.new)
126
+
127
+ output.url = "http://localhost:#{port}/good"
128
+ result = output.send(:send_events, [event], 1)
129
+ expect(result).to eq(false)
130
+ end
131
+
116
132
  it "returns true when the status is 200" do
117
133
  output.url = "http://localhost:#{port}/good"
118
134
  result = output.send(:send_events, [event], 1)
@@ -122,30 +138,30 @@ describe LogStash::Outputs::Timber do
122
138
  request = requests.first
123
139
  expect(request.env["CONTENT_TYPE"]).to eq("application/json")
124
140
  expect(request.env["HTTP_AUTHORIZATION"]).to eq("Basic MTIzOmFiY2QxMjM0")
125
- expect(request.env["HTTP_USER_AGENT"]).to eq("Timber Logstash/1.0.1")
141
+ expect(request.env["HTTP_USER_AGENT"]).to eq("Timber Logstash/1.0.2")
126
142
 
127
143
  parsed_body = JSON.parse!(request.body.read)
128
144
  expect(parsed_body.length).to eq(1)
129
145
 
130
146
  body_event = parsed_body.first
131
147
  timestamp_iso8601 = event.get("@timestamp").to_iso8601
132
- expect(body_event).to eq({"@timestamp"=>timestamp_iso8601, "message"=>"hi"})
148
+ expect(body_event).to eq({"dt"=>timestamp_iso8601, "message"=>"hi"})
133
149
  end
134
150
 
135
- it "handles fatal request errors" do
136
- allow(output.send(:http_client)).to receive(:post).and_raise("boom")
137
-
151
+ it "allows payloads conformed to the timber JSON schema" do
138
152
  output.url = "http://localhost:#{port}/good"
153
+ event = LogStash::Event.new({"$schema" => "https://raw.githubusercontent.com/timberio/log-event-json-schema/v2.4.2/schema.json", "message" => "my message", "context" => {"http" => {"path" => "/path"}}})
139
154
  result = output.send(:send_events, [event], 1)
140
- expect(result).to eq(false)
141
- end
155
+ expect(result).to eq(true)
156
+ expect(requests.length).to eq(1)
142
157
 
143
- it "handles retryable request errors" do
144
- expect(output.send(:http_client)).to receive(:post).exactly(3).times.and_raise(::Manticore::Timeout.new)
158
+ request = requests.first
159
+ parsed_body = JSON.parse!(request.body.read)
160
+ expect(parsed_body.length).to eq(1)
145
161
 
146
- output.url = "http://localhost:#{port}/good"
147
- result = output.send(:send_events, [event], 1)
148
- expect(result).to eq(false)
162
+ body_event = parsed_body.first
163
+ timestamp_iso8601 = event.get("@timestamp").to_iso8601
164
+ expect(body_event).to eq({"$schema"=>"https://raw.githubusercontent.com/timberio/log-event-json-schema/v2.4.2/schema.json", "context"=>{"http"=>{"path"=>"/path"}}, "message"=>"my message", "dt"=>timestamp_iso8601})
149
165
  end
150
166
  end
151
167
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-timber
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
  - Elastic