I got an alert recently from a Severity 016 error on a production system that I monitor.
The error message was:
"The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query"
It was good to know that setting up the alerts, operators, notifications and database mail all worked.
But it didn't help me find the culprit query. I looked in the plan cache, but couldn't be 100% sure what caused the alert.
I needed more information.
We had already setup a SQL Server Agent job for sp_whoisactive to log to a table, so I modified the alert to run that job the next time the alert fires and hopefully sp_whoisactive can capture the query.