You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
874 B

  1. # Signalling failures
  2. Append `/fail` to a ping URL and use it to actively signal a failure.
  3. Requesting the `/fail` URL will immediately mark the check as "down".
  4. You can use this feature to minimize the delay from your monitored service failing
  5. to you getting a notification.
  6. ## Python
  7. Below is a skeleton code example in Python which signals a failure when the
  8. work function returns an unexpected value or throws an exception:
  9. ```python
  10. import requests
  11. URL = "PING_URL"
  12. def do_work():
  13. # Do your number crunching, backup dumping, newsletter sending work here.
  14. # Return a truthy value on success.
  15. # Return a falsy value or throw an exception on failure.
  16. return True
  17. success = False
  18. try:
  19. success = do_work()
  20. finally:
  21. # On success, requests PING_URL
  22. # On failure, requests PING_URL/fail
  23. requests.get(URL if success else URL + "/fail")
  24. ```