Skip to content

Commit 31bf8a2

Browse files
committed
Add path and stream to dimensions if they exists
In Docker environment path is not setup but logs could be accuired from STDOUT stream. Change-Id: I755fa3d72bb81b61a4fa083fd974735bb13e4295
1 parent a776a3d commit 31bf8a2

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)