logstash-output-charrington 0.3.15 → 0.3.16

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: 5bc7440fc12c2dee8a2c47f7c30c9f95cd11c7ecf6905ccefc5cbecf21e6588b
4
- data.tar.gz: 409036adf2e56121fac87141d06686beda6d0d878bc7f1de1de14b58e58efd7b
3
+ metadata.gz: 94729829f8d0a679e21b264079ba18ded80a374afc2eedff99a063b9c40381bf
4
+ data.tar.gz: 382f8290e530f6ee78a93f53ab81ce7f5c6ab27385795aeb313ca8309f5ed1bf
5
5
  SHA512:
6
- metadata.gz: d793f1abbf99da18b9076bb1c36d101bc52657694cdef5ef645c80dc39d16092eedbd28b423fc45285934514c2210ccfb1f1ca2288fe947d501c3a08d7b92a1e
7
- data.tar.gz: 0500b6e35d903f450f29c3e521073486b5f523ffec9f3c89111610c65adf75e3b778050ca2340724dcbf03611dd07a57cac6f84bd796a50427bb1e8ee276919e
6
+ metadata.gz: 5b9e425e3eaf61785ce59e63fea1f39db54611f1cc1176bc5fc82c5be49a730b94627a394164ee76014a2a80d4940fc0fbde0b0582cf84e3e45f673195ba041f
7
+ data.tar.gz: 66f92a5bfb76cb400add4feff87409600baff3f70ede790ee98904df6bd9786831acc4a567167b64768b90f6048640d97c73cb8994c9a0e94c0b06ed4302c3ef
@@ -5,6 +5,8 @@ module Charrington
5
5
  # This service will create a table dynamically based on the JSON structure.
6
6
  # This is potentially called from Insert when an insert fails.
7
7
 
8
+ @@timestamp_columns = %w(published_at sent_at original_timestamp received_at timestamp)
9
+
8
10
  include Service
9
11
  include LogStash::Util::Loggable
10
12
  attr_reader :connection, :event, :table_name, :columns, :schema, :opts, :transformer
@@ -37,7 +39,7 @@ module Charrington
37
39
 
38
40
  def set_column_types
39
41
  columns.each do |column|
40
- if column == "published_at" || column == "sent_at"
42
+ if @@timestamp_columns.include?(column)
41
43
  column_types << "#{column} TIMESTAMP"
42
44
  next
43
45
  end
@@ -56,7 +58,7 @@ module Charrington
56
58
  when true, false
57
59
  column_types << "#{column} BOOLEAN"
58
60
  else
59
- column_types << "#{column} VARCHAR"
61
+ column_types << "#{column} VARCHAR(512)"
60
62
  end
61
63
  end
62
64
  end
@@ -69,9 +71,6 @@ module Charrington
69
71
  ]
70
72
  else
71
73
  [
72
- "original_timestamp TIMESTAMP DEFAULT NOW()",
73
- "received_at TIMESTAMP DEFAULT NOW()",
74
- "timestamp TIMESTAMP DEFAULT NOW()",
75
74
  "uuid_ts TIMESTAMP DEFAULT NOW()"
76
75
  ]
77
76
  end
@@ -18,6 +18,7 @@ module Charrington
18
18
  # TODO create a current_table_columns (alter_postgres_table.rb) query on the tracks table to get the current columns
19
19
  @@redshift_tracks_columns = %w(id app_name received_at uuid uuid_ts anonymous_id context_ip context_library_name context_library_version context_page_path context_page_referrer context_page_title context_page_url context_user_agent event event_text original_timestamp sent_at timestamp user_id user_uid context_campaign_medium context_campaign_name context_page_search context_campaign_source segment_dedupe_id context_campaign_content)
20
20
  @@postgres_tracks_columns = %w(anonymous_user app_name event published_at session_ip session_library_name session_library_version session_page_path session_page_referrer session_page_search session_page_title session_page_url session_user_agent user_id user_uid)
21
+ @@timestamp_columns = %w(published_at sent_at original_timestamp received_at timestamp)
21
22
 
22
23
  Error = Class.new(StandardError)
23
24
  EventNil = Class.new(Error)
@@ -174,7 +175,7 @@ module Charrington
174
175
  value = map[key]
175
176
  values << value
176
177
 
177
- if key == 'published_at' || key == 'sent_at'
178
+ if @@timestamp_columns.include?(key)
178
179
  format = java.text.SimpleDateFormat.new("yyyy-MM-dd'T'HH:mm:ss'Z'")
179
180
  parsed = format.parse(value)
180
181
  time = java.sql.Timestamp.new(parsed.getTime)
@@ -29,6 +29,9 @@ module Charrington
29
29
 
30
30
  handle_key_transform(event, "anonymous_id", "anonymous_user")
31
31
  handle_key_transform(event, "sent_at", "published_at")
32
+ handle_key_transform(event, "original_timestamp", "sent_at")
33
+ handle_key_transform(event, "received_at", "sent_at")
34
+ handle_key_transform(event, "timestamp", "sent_at")
32
35
 
33
36
  handle_meta_section(event)
34
37
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-charrington'
3
- s.version = '0.3.15'
3
+ s.version = '0.3.16'
4
4
 
5
5
  s.licenses = ['Apache-2.0']
6
6
  s.homepage = 'https://gitlab.podium.com/engineering/analytics/logstash-output-charrington'
@@ -253,4 +253,37 @@ describe LogStash::Outputs::Charrington do
253
253
  end
254
254
  end
255
255
 
256
+ describe 'a new payload has timestamp-related keys set to sent_at' do
257
+ let(:config) do
258
+ <<-CONFIG
259
+ input {
260
+ generator {
261
+ message => '{"app_name": "Web App", "event": "schemaless", "meta": { "type": "XML" }, "published_at": "2019-07-29T20:09:18Z", "user_id": "123", "user_uid": "456" }'
262
+ codec => 'json'
263
+ count => 1
264
+ }
265
+ }
266
+
267
+ output {
268
+ charrington {
269
+ connection_string => '#{@url}'
270
+ driver_jar_path => '#{driver_path}'
271
+ schema => ''
272
+ transformer => 'redshift'
273
+ }
274
+ }
275
+ CONFIG
276
+ end
277
+
278
+ it 'creates a table with timestamp-related keys and inserts a record with timestamp-related keys same as sent_at' do
279
+ drop_table('tracks')
280
+ create_tracks_table
281
+ drop_table('schemaless')
282
+ run_pipeline
283
+ expect(query('SELECT * FROM schemaless')).to match_array([
284
+ {:anonymous_id=>"", :app_name=>"Web App", :event=>"schemaless", :event_text=>"schemaless", :id=>a_kind_of(String), :original_timestamp=>"2019-07-29 20:09:18", :received_at=>"2019-07-29 20:09:18", :sent_at=>"2019-07-29 20:09:18", :timestamp=>"2019-07-29 20:09:18", :type=>"XML", :user_id=>"123", :user_uid=>"456", :uuid_ts=>a_kind_of(String)}
285
+ ])
286
+ expect(query('SELECT COUNT(1) FROM schemaless').first[:count]).to eq("1")
287
+ end
288
+ end
256
289
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-charrington
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - dconger
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-07-31 00:00:00.000000000 Z
13
+ date: 2019-08-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
@@ -182,8 +182,6 @@ files:
182
182
  - README.md
183
183
  - THANKS.md
184
184
  - lib/com/zaxxer/HikariCP/2.7.2/HikariCP-2.7.2.jar
185
- - lib/commons-io/commons-io/2.4/commons-io-2.4.jar
186
- - lib/de/flapdoodle/embed/de.flapdoodle.embed.process/2.0.2/de.flapdoodle.embed.process-2.0.2.jar
187
185
  - lib/logstash-output-charrington_jars.rb
188
186
  - lib/logstash/outputs/charrington.rb
189
187
  - lib/logstash/outputs/charrington/alter_postgres_table.rb
@@ -195,16 +193,9 @@ files:
195
193
  - lib/logstash/outputs/charrington/service.rb
196
194
  - lib/logstash/outputs/charrington/transform_postgres.rb
197
195
  - lib/logstash/outputs/charrington/transform_redshift.rb
198
- - lib/net/java/dev/jna/jna-platform/4.0.0/jna-platform-4.0.0.jar
199
- - lib/net/java/dev/jna/jna/4.0.0/jna-4.0.0.jar
200
- - lib/org/apache/commons/commons-compress/1.10/commons-compress-1.10.jar
201
- - lib/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
202
196
  - lib/org/apache/logging/log4j/log4j-api/2.6.2/log4j-api-2.6.2.jar
203
197
  - lib/org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar
204
- - lib/org/postgresql/postgresql/42.2.5/postgresql-42.2.5.jar
205
198
  - lib/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar
206
- - lib/ru/yandex/qatools/embed/postgresql-embedded/2.10/postgresql-embedded-2.10.jar
207
- - lib/ru/yandex/qatools/embed/postgresql-embedded/2.8/postgresql-embedded-2.8.jar
208
199
  - logstash-output-charrington.gemspec
209
200
  - spec/charrington_spec_helper.rb
210
201
  - spec/logstash-output-charrington_test_jars.rb