How about trying this and see if it works out for you:
id script status host=d* script=test* "log=Script "
| rex field=_raw "log=Script\s*(?<statusString>[\S]+)"
| eval status=case(statusString=="started", "started", statusString=="exit", "success", statusString=="terminated", "failed", 1=1, "unknown")
| eventstats min(_time) as start, max(_time) as end by id , script
| search status="exit" OR status="terminated"
| table id, script, status, start, end
| eval duration=end-start
| eval start=strftime(start, "%Y/%m/%d %T.%3Q")
| eval end=strftime(end, "%Y/%m/%d %T.%3Q")
... View more