You can use Cloud Logging for this.
- Go to the Cloud Logging page and filter your logs
- Then select the part of the logs that you want (in my screen shot is the 200 HTTP response code), and click on "show matching entries"

- Now, in the query builder, you have the matching entry that you select

You can change it, the value (400 instead of 200) the equality by > or <,... So, you can see in the documentation how to build a Cloud Logging filter
- Then go to Action and click on create metrics

- Now create your metric and name it.

- Finally, click on the 3 dots on the right and select create an alert on this metric

- From there, follow the wizard. Name your condition, define your threshold and notification channels. I think it's the easiest part (but if you need guidance, let me know)