|
4 | 4 | require "logstash/event"
|
5 | 5 |
|
6 | 6 | describe LogStash::Outputs::LMLogs do
|
7 |
| - let(:sample_event) { LogStash::Event.new("message" => "hello this is log") } |
| 7 | + let(:sample_event) { LogStash::Event.new("message" => "hello this is log","event" => {"sequence" => 0,"original" => "simple logstash msg from me running with proxy settings"})} |
8 | 8 | let(:client) { @lmlogs.client }
|
9 | 9 | let(:sample_lm_logs_event){{"message" => "hello this is log 1", "_lm.resourceId" => {"test.property" => "host1"}, "timestamp" => "2021-03-22T04:28:55.907121106Z"}}
|
10 | 10 |
|
|
35 | 35 | event2 = LogStash::Event.new("message" => "hello this is log 2", "host" => "host2")
|
36 | 36 | event3 = LogStash::Event.new("message" => "hello this is log 3", "host" => "host3")
|
37 | 37 | expect(client).to receive(:post).once.with("https://localhost.logicmonitor.com/rest/log/ingest",hash_including(:body => LogStash::Json.dump(
|
38 |
| - [{"message" => "hello this is log 1", "_lm.resourceId" => {"test.property" => "host1"}, "timestamp" => event1.timestamp.to_s}, |
39 |
| - {"message" => "hello this is log 2", "_lm.resourceId" => {"test.property" => "host2"}, "timestamp" => event2.timestamp.to_s}, |
40 |
| - {"message" => "hello this is log 3", "_lm.resourceId" => {"test.property" => "host3"}, "timestamp" => event3.timestamp.to_s} |
| 38 | + [{ "host" => "host1", "message" => "hello this is log 1","@version":"1", "_lm.resourceId" => {"test.property" => "host1"}, "timestamp" => event1.timestamp.to_s,}, |
| 39 | + {"host" => "host2","message" => "hello this is log 2","@version":"1", "_lm.resourceId" => {"test.property" => "host2"}, "timestamp" => event2.timestamp.to_s}, |
| 40 | + {"host" => "host3","message" => "hello this is log 3","@version":"1", "_lm.resourceId" => {"test.property" => "host3"}, "timestamp" => event3.timestamp.to_s} |
41 | 41 | ]
|
42 | 42 | ))).and_call_original
|
43 | 43 | @lmlogs.multi_receive([event1, event2, event3])
|
|
66 | 66 | document = [sample_lm_logs_event]
|
67 | 67 |
|
68 | 68 | lm_logs_event = {"message" => "hello this is log 2", "_lm.resourceId" => {"test.property" => "host3"}, "timestamp" => "2021-03-22T04:28:55.909421106Z"}
|
69 |
| - |
| 69 | + |
70 | 70 | document_expected = [sample_lm_logs_event,lm_logs_event]
|
71 | 71 | expect(client).to receive(:post).exactly(0).times.and_call_original
|
72 | 72 |
|
|
0 commit comments