Write a program to periodically query a health endpoint and alert if the service fails three times consecutively.