How to mark a check as warning or error if a check fails multiple times within a certain time range using Sensu?
You want to use the occurrences filter, which is included by default in Sensu.

First, apply the filter to your handlers:

{
  "handlers": {
    "email": {
      "...": "...",
      "filters": ["occurrences"]
    }
  }
}


Then, in your check, you can use the occurrences attribute to only trigger the handler once the check fails or warns a certain number of times in a row:

{
  "checks": {
    "check-http": {
      "...": "...",
      "occurrences": 2
    }
  }
}