logstash-filter-transaction_time 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
  SHA1:
3
- metadata.gz: 791175d5aab745baae8183abe08c091593f0d0ca
4
- data.tar.gz: d6d2326111fb55b7b36816dbc068b3f63f8a58c3
3
+ metadata.gz: edc1cb278d1570f38410dfb0adcbc6cb916051b8
4
+ data.tar.gz: e7af3ddd9246545057682d1f20570fc392f361fc
5
5
  SHA512:
6
- metadata.gz: 3c6ec8cda7e6da7c3dd9b32c0a347a5bfd811d4ecf182341b8dd054bf3b94bcaa8b40c76ef3ad5447dcb073a83ccfaf51102c865a08d8f72182343740508e801
7
- data.tar.gz: 9733638d214930bebae4a08f0aa22046a32bed7f12394df2ff6f7446e76004684d6e65a9bb2d44636b46c14427ac68ca21d792fcbd929fac1f528e1207710aa2
6
+ metadata.gz: 6ae4104911a6088a0708b5d8f0135af8e28ddf7e1c96b50e30b6e7c1ee8538bf48a1b3f2921e022ff53af1e9f5433c9bcdefaca3bff1ca9735d602121b83200a
7
+ data.tar.gz: aef8f360cbce787e8482f2e1f24be6fa73e37503335837323f7876aa1d1da3790f28e6a8557f8159e4e1bcf0b6c930480164b4a5f03a7c130cc3b507b7c23b00
@@ -56,8 +56,8 @@ require "logstash/namespace"
56
56
  # }
57
57
  # }
58
58
  # transaction_time {
59
- # uid_field => "Transaction-unique field"
60
- # filter_tag => "transaction tag"
59
+ # uid_field => "UID"
60
+ # filter_tag => "Transaction"
61
61
  # }
62
62
  # }
63
63
  #
@@ -65,6 +65,8 @@ require "logstash/namespace"
65
65
  # is added for a specific set of messages.
66
66
  # This tag is then used in the transaction_time as filter_tag.
67
67
  # Only the messages with this tag will be evaluated.
68
+ # Note: Do not use reserved name "TransactionTime"
69
+ # which is added to all events created by this plugin
68
70
  #
69
71
  # The attach_event parameter can be used to append information from one of the events to the
70
72
  # new transaction_time event. The default is to not attach anything.
@@ -89,6 +91,7 @@ class LogStash::Filters::TransactionTime < LogStash::Filters::Base
89
91
  # Override the new events timestamp with the oldest or newest timestamp or keep the new one (set when logstash has processed the event)
90
92
  config :replace_timestamp, :validate => ['keep', 'oldest', 'newest'], :default => 'keep'
91
93
  # Tag used to identify transactional events. If set, only events tagged with the specified tag attached will be concidered transactions and be processed by the plugin
94
+ # Do not use reserved tag name "TransactionTime"
92
95
  config :filter_tag, :validate => :string
93
96
  # Whether or not to attach one or none of the events in a transaction to the output event.
94
97
  # Defaults to 'none' - which reduces memory footprint by not adding the event to the transactionlist.
@@ -118,10 +121,15 @@ class LogStash::Filters::TransactionTime < LogStash::Filters::Base
118
121
 
119
122
  @logger.debug("Received UID", uid: uid)
120
123
 
121
- if (@filter_tag.nil? || (!event.get("tags").nil? && event.get("tags").include?(@filter_tag)))
124
+ #Dont use filter-plugin on events created by this filter-plugin
125
+ #Dont use filter on anything else but events with the filter_tag if specified
126
+ if (!uid.nil? && (event.get("tags").nil? || !event.get("tags").include?(TRANSACTION_TIME_TAG)) &&
127
+ (@filter_tag.nil? || (!event.get("tags").nil? && event.get("tags").include?(@filter_tag))))
128
+ filter_matched(event)
122
129
  @mutex.synchronize do
123
130
  if(!@transactions.has_key?(uid))
124
131
  @transactions[uid] = LogStash::Filters::TransactionTime::Transaction.new(event, uid, @storeEvent)
132
+
125
133
  else #End of transaction
126
134
  @transactions[uid].addSecond(event,@storeEvent)
127
135
  transaction_event = new_transactiontime_event(@transactions[uid])
@@ -132,10 +140,6 @@ class LogStash::Filters::TransactionTime < LogStash::Filters::Base
132
140
  end
133
141
  end
134
142
 
135
- event.set("uid_field", @uid_field)
136
-
137
- # filter_matched should go in the last line of our successful code
138
- filter_matched(event)
139
143
  end # def filter
140
144
 
141
145
 
@@ -173,33 +177,36 @@ class LogStash::Filters::TransactionTime < LogStash::Filters::Base
173
177
  end
174
178
 
175
179
  def new_transactiontime_event(transaction)
180
+
181
+
176
182
  case @attach_event
177
183
  when 'oldest'
178
- event = transaction.getOldestEvent()
184
+ transaction_event = transaction.getOldestEvent()
179
185
  when 'first'
180
- event = transaction.firstEvent
186
+ transaction_event = transaction.firstEvent
181
187
  when 'newest'
182
- event = transaction.getNewestEvent()
188
+ transaction_event = transaction.getNewestEvent()
183
189
  when 'last'
184
- event = transaction.lastEvent
185
- else
186
- event = LogStash::Event.new
190
+ transaction_event = transaction.lastEvent
191
+ else
192
+ transaction_event = LogStash::Event.new
187
193
  end
188
- event.set(HOST_FIELD, Socket.gethostname)
194
+ transaction_event.set(HOST_FIELD, Socket.gethostname)
195
+
189
196
 
190
- event.tag(TRANSACTION_TIME_TAG)
191
- event.set(TRANSACTION_TIME_FIELD, transaction.diff)
192
- event.set(TRANSACTION_UID_FIELD, transaction.uid)
193
- event.set(TIMESTAMP_START_FIELD, transaction.getOldestTimestamp())
197
+ transaction_event.tag(TRANSACTION_TIME_TAG)
198
+ transaction_event.set(TRANSACTION_TIME_FIELD, transaction.diff)
199
+ transaction_event.set(TRANSACTION_UID_FIELD, transaction.uid)
200
+ transaction_event.set(TIMESTAMP_START_FIELD, transaction.getOldestTimestamp())
194
201
 
195
202
  if(@replace_timestamp.eql?'oldest')
196
- event.set("@timestamp", transaction.getOldestTimestamp())
203
+ transaction_event.set("@timestamp", transaction.getOldestTimestamp())
197
204
  elsif (@replace_timestamp.eql?'newest')
198
- event.set("@timestamp", transaction.getNewestTimestamp())
205
+ transaction_event.set("@timestamp", transaction.getNewestTimestamp())
199
206
  end
200
207
 
201
208
 
202
- return event
209
+ return transaction_event
203
210
  end
204
211
 
205
212
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-transaction_time'
3
- s.version = '1.0.1'
3
+ s.version = '1.0.2'
4
4
  s.licenses = ['Apache-2.0','Apache License (2.0)']
5
5
  s.summary = 'Writes the time difference between two events in a transaction to a new event'
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. Source-code and documentation available at github: https://github.com/AddinITAB/logstash-filter-transaction_time'
@@ -24,7 +24,7 @@ describe LogStash::Filters::TransactionTime do
24
24
  expect(subject.get('timestamp_tag')).to eq('testing')
25
25
  end
26
26
 
27
- sample("uid_field" => "some text") do
27
+ sample("uid_field" => "uid") do
28
28
  expect(subject).to include("uid_field")
29
29
  expect(subject.get('uid_field')).to eq('uid')
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-transaction_time
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
  - Tommy Welleby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement