File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
azure/activity_logs_monitoring Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -381,14 +381,38 @@ class EventhubLogHandler {
381381 this . records . push ( originalRecord ) ;
382382 }
383383 } else {
384- this . records . push ( originalRecord ) ;
384+ this . records . push ( this . fixPropertiesJsonString ( originalRecord ) ) ;
385385 }
386386 } else {
387387 record = this . addTagsToStringLog ( record ) ;
388388 this . records . push ( record ) ;
389389 }
390390 }
391391
392+ fixPropertiesJsonString ( record ) {
393+ try {
394+ // Check if properties field is a string
395+ if ( typeof record . properties === 'string' ) {
396+ // If it is a string, check if it is a malformed JSON String
397+ // By checking for ':'
398+ if ( record . properties . includes ( "':'" ) ) {
399+ // If the check is true, find / replace single quotes
400+ // with double quotes, to make a proper JSON
401+ // which is then converted into a JSON Object
402+ record . properties = JSON . parse ( record . properties . replace ( / ' / g, '"' ) ) ;
403+ return record ;
404+ } else {
405+ return record ;
406+ }
407+ } else {
408+ return record ;
409+ }
410+ } catch {
411+ this . context . error ( 'Unable to fix properties field to JSON Object' ) ;
412+ return record ;
413+ }
414+ }
415+
392416 handleLogs ( logs ) {
393417 let logsType = this . getLogFormat ( logs ) ;
394418 switch ( logsType ) {
You can’t perform that action at this time.
0 commit comments