Skip to content

Commit

Permalink
Merge pull request #55 from SumoLogic/rmiller-fix-sumo-key-hash-tuple
Browse files Browse the repository at this point in the history
Fix sumo_key hash tuple to support colons
  • Loading branch information
samjsong authored Oct 25, 2019
2 parents 7fc9169 + c1f296b commit ac4c751
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/fluent/plugin/out_sumologic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def sumo_key(sumo_metadata, chunk)
fields = sumo_metadata['fields'] || ""
fields = extract_placeholders(fields, chunk) unless fields.nil?

"#{source_name}:#{source_category}:#{source_host}:#{fields}"
{ :source_name => "#{source_name}", :source_category => "#{source_category}",
:source_host => "#{source_host}", :fields => "#{fields}" }
end

# Convert timestamp to 13 digit epoch if necessary
Expand Down Expand Up @@ -265,7 +266,8 @@ def write(chunk)

# Push logs to sumo
messages_list.each do |key, messages|
source_name, source_category, source_host, fields = key.split(':')
source_name, source_category, source_host, fields = key[:source_name], key[:source_category],
key[:source_host], key[:fields]
@sumo_conn.publish(
messages.join("\n"),
source_host =source_host,
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_out_sumologic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def test_batching_different_fields
driver.feed("output.test", time, {'message' => 'test1'})
driver.feed("output.test", time, {'message' => 'test2', '_sumo_metadata' => {"fields": "foo=bar"}})
driver.feed("output.test", time, {'message' => 'test3', '_sumo_metadata' => {"fields": "foo=bar,sumo=logic"}})
driver.feed("output.test", time, {'message' => 'test4', '_sumo_metadata' => {"fields": "foo=bar,abc=123"}})
driver.feed("output.test", time, {'message' => 'test4', '_sumo_metadata' => {"fields": "foo=bar,master_url=https://100.64.0.1:443"}})
end
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
Expand All @@ -470,7 +470,7 @@ def test_batching_different_fields
body: /\A{"timestamp":\d+.,"message":"test3"}\z/,
times:1
assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'X-Sumo-Fields' => 'foo=bar,abc=123'},
headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'X-Sumo-Fields' => 'foo=bar,master_url=https://100.64.0.1:443'},
body: /\A{"timestamp":\d+.,"message":"test4"}\z/,
times:1
end
Expand Down

0 comments on commit ac4c751

Please sign in to comment.