Skip to content

Commit 45abeb5

Browse files
author
Witek Bedyk
authored
Merge pull request #4 from matrixik/testowe
Add path and stream to dimensions if they exists
2 parents a776a3d + 31bf8a2 commit 45abeb5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/logstash/outputs/monasca_log_api.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ def encode(event)
140140

141141
def generate_log_from_event(event)
142142
message = event.to_hash['message']
143-
path = event.to_hash['path']
143+
path = event.to_hash['path'] if event.to_hash['path']
144+
stream = event.to_hash['stream'] if event.to_hash['stream']
144145
local_dims = JSON.parse(event.to_hash['dimensions'].to_s) if
145146
event.to_hash['dimensions']
146147
type = event.to_hash['type'] if event.to_hash['type']
147148
cross_tenant = event.to_hash['cross_tenant'] if
148149
event.to_hash['cross_tenant']
149150

150-
log = { 'message' => message, 'dimensions' => { 'path' => path }}
151+
log = { 'message' => message, 'dimensions' => {} }
152+
path && log['dimensions']['path'] = path
153+
stream && log['dimensions']['stream'] = stream
154+
151155
log[JSON_DIMS]['type'] = type if type
152156
if local_dims
153157
begin

0 commit comments

Comments
 (0)