Documentation How string matching works (contains)

You can specify a string to match in the response body using the "Contains" field. A small tooltip on focus gives more details:

If you specify a string here (something else than a 3 digit number, as that would be considered a status code), updown will check for the presence of the specified string in the response body instead of checking the HTTP status code. The main reason to do this is to be able to detect changes in the response even if it stays under the same HTTP status code. For example by checking for the important content of an HTML page you could detect defacing, a database/caching issue or other type of improper error handling shown as a 200OK response. It can also be used to implement bespoke monitoring of an API or healcheck endpoint. Finally this can be used as a way to force a GET request instead of HEAD if your server is having trouble responding in an HTTP compliant manner and you can't fix it.

Here are the details of how this works (as of 2025-02-01):
- The matching string must be 1000 bytes maximum and valid UTF-8.
- updown will have to issue a GET request instead of HEAD (which is the default when available).
- Matching is only performed in the first 1 MB of response, after that the body streaming is stopped midway to avoid consuming too much resources.
- HTTP status is ignored in that case, so you can monitor a 403 page for example, as long as the string is found updown is happy. Note: you can also do that by specifying the expected status code if you don't care about the content
- Updown will still follow 3xx redirections before looking for the expected string in the first non-3xx response.
- The new lines and spaces will be ignored/stripped in both your choosen string and the response body. This is to avoid unexpected false positives caused by the high number of unimportant spaces and newlines in raw HTML. Note: careful if you're using non-breaking spaces as they are preserved
- If the string can't be found in the raw HTML, updown will also try parsing the HTML (using an HTML5 compliant parser) to see if it can find a match in the resulting text. This is helpful if you simply copy/paste something from the web page which actually contains HTML tags inside. For example My important title will match My<em>important</em><br>title


Adrien Rey-Jarthon
Created on February 01, 2025