I have logs with data containing key=value pairs separated by space.
time="2022-08-10T16:03:23Z" Event=xyz TxPkts=9 DroppedPkts=0 FailedRetries=0 SuccessRate=100.00
I want to print the entire line, where the SuccessRate is < 99.
So far I've used awk to figure out where the SuccessRate is < 99, but it only prints the field itself, not the entire line:
awk '/SuccessRate/ {print $NF}' file | awk -F "=" '$2<=99{print ;}'
Doing this prints out :
SuccessRate=98.64
SuccessRate=0.00
SuccessRate=16.09
...
However, I want to print the entire line when the condition is met:
time="2022-08-10T16:03:23Z" Event=xyz TxPkts=9 DroppedPkts=0 FailedRetries=0 SuccessRate=98.64
time="2022-08-10T16:03:23Z" Event=xyz TxPkts=9 DroppedPkts=0 FailedRetries=0 SuccessRate=0.00
...
Not sure how to do it without the extra pipe. Additionally, how would I do this if the field I was interested in was not the last field in the line? i.e. what if I wanted to print if TxPkts met a condition?