Creating a new field through painless scripts to calculate the difference between two timestamp

Is the Payload field a nested field? Then that might be the issue.
From what I see this should really work:
doc['@timestamp'].value.toInstant().toEpochMilli() - doc['utc_time'].value.toInstant().toEpochMilli()