I want to do a field extraction for my sourcetype under the Fields-> Calculated Fields section. Confused how to draft the if condition to achieve the following logic.
Condition.
Some events contain only the userid field, for those, check if it is not null/empty, then fetch the userid field as user or fill unknown
Some events contain both userid and cmdid field, in this case (if the event has both these fields) cmdid is the real user field. so the logic in both cases should first compare the existence of those 2 fields and then accordingly derive.
Try this
user = coalesce(cmdid, userid, "unknown")
Try this
user = coalesce(cmdid, userid, "unknown")