logstash-filter-fix_protocol 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: 01e4c787451d2df8a4d094719f6773f41dc32b48
4
- data.tar.gz: 59d92aec02f3566804710507b42e046814817100
3
+ metadata.gz: 454431f7e36a07d087e15a1b6c2f18ea274557de
4
+ data.tar.gz: 997359c4fab37712934c8252bf209039ee782b56
5
5
  SHA512:
6
- metadata.gz: 1c20c43d362899f2423da2799621d48c5af3f9c2775313a33ddac837ca68d93098b34ed098aa2a214235f0d931a0aa615699a5c22651fd455ff2ef16cb0681fb
7
- data.tar.gz: 27940ad87626f23d13428a78fc243ede4f453551d35404f5af3592a8ec75b508aaaf494769b0a108424864ce0c1db1d7bbf8be701661e60654ff287c39d98c09
6
+ metadata.gz: 841e0c9cbbfc740092d1f52a7d9aab62c54a94370d447d9109a73e179eb8a57fdd4e04d396caec903bf2f8a2f4d52155a24785fca77417501b6ea2bc98ffed17
7
+ data.tar.gz: 2b45940ea8d8100286a47f35317daca43a0d244a10e179835c2b3ecac71eb3855ee9bf2a1bc90f9d6820ff62ba185cb7120ce3f8b7d8c805ff6032da94f04c1d
data/README.md CHANGED
@@ -23,11 +23,11 @@ $ /opt/logstash/bin/plugin install logstash-filter-fix_protocol
23
23
 
24
24
  | Setting | Input type | Required | Default Value |
25
25
  | ----------------------- | ----------------| ---------| ------------------ |
26
- | message | string/variable | Yes | "Fix String" |
26
+ | fix_message | string/variable | Yes | "message" |
27
27
  | data_dictionary_path | string | Yes | "/PATH/TO/YOUR/DD" |
28
28
  | session_dictionary_path | string | No | nil |
29
29
 
30
- **message**
30
+ **fix_message**
31
31
  + value type is a string
32
32
  + required
33
33
 
@@ -58,10 +58,10 @@ input {
58
58
  }
59
59
  filter {
60
60
  grok {
61
- match => ["message","%{TIMESTAMP_ISO8601:timestamp} %{GREEDYDATA:fix_string}: %{GREEDYDATA:fix_message}"]
61
+ match => ["message","%{TIMESTAMP_ISO8601:timestamp} %{GREEDYDATA:fix_session}: %{GREEDYDATA:fix_string}"]
62
62
  }
63
63
  fix_protocol {
64
- message => fix_message
64
+ fix_message => fix_string
65
65
  session_dictionary_path => "/PATH/TO/FIX/5.0/SESSION/DICTIONARY/FIX.xml"
66
66
  data_dictionary_path => "/PATH/TO/FIX/5.0/DATA/DICTIONARY/FIX.xml"
67
67
  }
@@ -12,7 +12,7 @@ module LogStash
12
12
 
13
13
  config_name "fix_protocol"
14
14
 
15
- config :message, validate: :string, default: "Hello"
15
+ config :fix_message, validate: :string, default: "message"
16
16
 
17
17
  config :data_dictionary_path, validate: :string, default: "/PATH/TO/YOUR/DD"
18
18
  config :session_dictionary_path, validate: :string, default: nil
@@ -34,22 +34,32 @@ module LogStash
34
34
  end
35
35
 
36
36
  def filter(event)
37
- if event["fix_message"]
38
- fix_message = FixMessage.new(event["fix_message"], data_dictionary, session_dictionary)
39
-
40
- fix_hash = fix_message.to_hash
41
-
42
- fix_hash.each do |key, value|
43
- begin
44
- event[key] = value
45
- rescue NoMethodError => e
46
- puts "********"
47
- puts "WARNING: Could not correctly parse #{event["fix_message"]}"
48
- puts JSON.pretty_generate(fix_hash)
49
- puts "Message: #{e.message}"
50
- puts "********"
51
- ensure
52
- next
37
+ message_string = event[config["fix_message"]]
38
+
39
+ if message_string
40
+ fix_message = nil
41
+
42
+ begin
43
+ fix_message = FixMessage.new(message_string, data_dictionary, session_dictionary)
44
+ rescue Java::Quickfix::InvalidMessage
45
+ event["tags"] = ["_fix_parse_failure"]
46
+ end
47
+
48
+ if fix_message
49
+ fix_hash = fix_message.to_hash
50
+
51
+ fix_hash.each do |key, value|
52
+ begin
53
+ event[key] = value
54
+ rescue NoMethodError => e
55
+ puts "********"
56
+ puts "WARNING: Could not correctly parse #{event["fix_message"]}"
57
+ puts JSON.pretty_generate(fix_hash)
58
+ puts "Message: #{e.message}"
59
+ puts "********"
60
+ ensure
61
+ next
62
+ end
53
63
  end
54
64
  end
55
65
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "logstash-filter-fix_protocol"
7
- s.version = "0.1.1"
7
+ s.version = "0.1.2"
8
8
  s.authors = ["Connamara Systems"]
9
9
  s.email = ["info@connamara.com"]
10
10
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe LF::FixProtocol do
4
4
  let(:fix_5_config) do
5
5
  {
6
- "message" => "fix_message",
6
+ "fix_message" => "message",
7
7
  "session_dictionary_path" => load_fixture("FIXT11.xml"),
8
8
  "data_dictionary_path" => load_fixture("FIX50SP1.xml")
9
9
  }
@@ -11,7 +11,7 @@ describe LF::FixProtocol do
11
11
 
12
12
  let(:fix_4_config) do
13
13
  {
14
- "message" => "fix_message",
14
+ "fix_message" => "message",
15
15
  "data_dictionary_path" => load_fixture("FIX42.xml")
16
16
  }
17
17
  end
@@ -36,12 +36,23 @@ describe LF::FixProtocol do
36
36
  end
37
37
  end
38
38
 
39
+ context 'invalid message' do
40
+ config fix_4_configuration
41
+
42
+ invalid_msg = "8=invalid_stuff"
43
+
44
+ sample(invalid_msg) do
45
+ insist { subject["tags"] } == ["_fix_parse_failure"]
46
+ insist { subject["message"] } == invalid_msg
47
+ end
48
+ end
49
+
39
50
  context 'an incoming execution report' do
40
51
  config fix_4_configuration
41
52
 
42
53
  execution = "8=FIXT.1.1\x0135=8\x0149=ITG\x0156=SILO\x01315=8\x016=100.25\x01410=50.25\x01424=23.45\x01411=Y\x0143=N\x0140=1\x015=N\x01"
43
54
 
44
- sample("fix_message" => execution) do
55
+ sample(execution) do
45
56
  filtered_event = subject
46
57
  insist { filtered_event["BeginString"] } == "FIXT.1.1"
47
58
  insist { filtered_event["MsgType"] } == "ExecutionReport"
@@ -57,7 +68,7 @@ describe LF::FixProtocol do
57
68
 
58
69
  execution = "8=FIX.4.2\x019=240\x0135=8\x0134=6\x0149=DUMMY_INC\x0152=20150826-23:10:17.744\x0156=ANOTHER_INC\x0157=Firm_B\x011=Inst_B\x016=0\x0111=151012569\x0117=ITRZ1201508261_24\x0120=0\x0122=8\x0131=1010\x0132=5\x0137=ITRZ1201508261_12\x0138=5\x0139=2\x0140=2\x0141=best_buy\x0144=1011\x0154=1\x0155=ITRZ1\x0160=20150826-23:10:15.547\x01150=2\x01151=0\x0110=227\x01"
59
70
 
60
- sample("fix_message" => execution) do
71
+ sample(execution) do
61
72
  expect { subject }.to output.to_stdout
62
73
  filtered_event = subject
63
74
  insist { filtered_event["BeginString"] } == "FIX.4.2"
@@ -7,7 +7,7 @@ module FixConfiguration
7
7
  <<-CONFIG
8
8
  filter {
9
9
  fix_protocol {
10
- message => fix_message
10
+ fix_message => message
11
11
  session_dictionary_path => "#{ load_fixture("FIXT11.xml") }"
12
12
  data_dictionary_path => "#{ load_fixture("FIX50SP1.xml") }"
13
13
  }
@@ -19,7 +19,7 @@ module FixConfiguration
19
19
  <<-CONFIG
20
20
  filter {
21
21
  fix_protocol {
22
- message => fix_message
22
+ fix_message => message
23
23
  data_dictionary_path => "#{ load_fixture("FIX42.xml") }"
24
24
  }
25
25
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-fix_protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connamara Systems
@@ -158,7 +158,7 @@ files:
158
158
  - lib/logstash/filters/data_dictionary.rb
159
159
  - lib/logstash/filters/fix_message.rb
160
160
  - lib/logstash/filters/fix_protocol.rb
161
- - logstash-filter-fix_message_filter.gemspec
161
+ - logstash-filter-fix_protocol.gemspec
162
162
  - spec/filters/fix_message_spec.rb
163
163
  - spec/filters/fix_protocol_spec.rb
164
164
  - spec/fixtures/FIX42.xml