Do not use map when it is not needed.
Is the position of the $field1$ value always the word directly before the phrase "Successfully pushed to system"?
To verify, try this... make sure the capitalization and wordign in the rex is exactly the same as the record...
(index=foo2 "Successfully pushed to system")
| head 10
| rex "\b(?\w+)\s+Successfully pushed to system"
If the above properly extracts the field1 value, then run this...
(index=foo1 "Sending message to queue") OR (index=foo2 "Successfully pushed to system")
| dedup field1 keepempty=true
| rex "\b(?\w+)\s+Successfully pushed to system"
| eval unit=case(index=foo2,1)
| stats sum(unit) as count by field1
... otherwise modify the rex until it is properly extracting the field1 value from the message, then proceed with the stats command
The lesson here is, if a human can tell what the field1 value should be by looking at the layout of the event, then there is a way to build the field1 field, so you do that then use stats.
... View more