How to create a report using awk - gensub function on FIX gateway log

fix-technology

#1

below is the an example fix messages, considering we have only 2 reject messages on this specific gateway.
and also the AWK gensub command to get the time, order ID and Reject message (tag 58)

[PAVANFIX@HOST logs]$ zgrep 150=8 OUTBOUND_BANK_FIRMA_FIRMB.log.2018-09-04.gz | less
10:02:01.420 INFO [JsonThread] - FIX.4.2:FIRMA->PKFIX: 8=FIX.4.2^A9=295^A35=8^A34=2133^A49=FIRMA^A52=20180904-14:02:01.420^A56=FIRMB^A57=JOHN^A128=BANK^A1=332^A6=0^A11=1809040000000ABCDEF^A14=0^A17=ABCD809040004379EF^A20=0^A29=1
^A37=QWER80904000059977^A38=210^A39=8^A40=1^A47=A^A54=2^A55=PKK^A58=StopPrice only supported on STOP and STOP_LIMIT orders^A59=0^A75=20180904^A99=0^A150=8^A151=0^A10=252^A
13:15:30.672 INFO [JsonThread] - FIX.4.2:FIRMA->PKFIX: 8=FIX.4.2^A9=279^A35=8^A34=225243^A49=FIRMA^A52=20180904-17:15:30.672^A56=FIRMB^A57=JOHN^A128=BANK^A1=334^A6=0^A11=1809040000000GHIJKL^A14=0^A17=712180904000959849^A20=0^A29=1
^A37=QEER80904000059977^A38=1400^A39=8^A40=1^A47=A^A54=1^A55=PKK^A58=End time should be after current time^A59=0^A65=A^A75=20180904^A150=8^A151=0^A10=108^A

[PAVANFIX@HOST logs]$ zgrep -w 150=8 OUTBOUND_BANK_FIRMA_FIRMB.log.2018-09-04.gz | tr ‘\001’ ‘|’ | sed ‘s/ INFO /,/g’ | awk 'BEGIN {print “\n|----Time—| |----Order_ID-----| |----------------------------------Reason-------------------------------------|n”} {x=gensub(/(.),.11=(.)|14.58=(.)|59./ , " \1 \2 \3" , “g”) ; print x;} ’ ; date

|----Time—| |----Order_ID-----| |----------------------------------Reason-------------------------------------|n
10:02:01.420 1809040000000ABCDEF StopPrice only supported on STOP and STOP_LIMIT orders
13:15:30.672 1809040000000GHIJKL End time should be after current time


#2

Nice, but I wonder how the sub-regexp (.) matches several letters…


#3

ahh, good question. it is actually .* which I initially typed but the final editor removed * from it


#4

Yes, editor markup may be tricky…:grinning:


#5

You can escape “*” with a single backslash ("\") to avoid interpretation as markdown command for italic emphasis.

[PAVANFIX@HOST logs]$ zgrep -w 150=8 OUTBOUND_BANK_FIRMA_FIRMB.log.2018-09-04.gz | tr ‘\001’ ‘|’ | sed ‘s/ INFO /,/g’ | awk 'BEGIN {print “\n|----Time—| |----Order_ID-----| |----------------------------------Reason-------------------------------------|n”} {x=gensub(/(.*),.11=(.*)|14.58=(.*)|59./ , " \1 \2 \3" , “g”) ; print x;} ’ ; date