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.

398 lines
9.6 KiB

3 years ago
3 years ago
  1. # Pinging API
  2. With the Pinging API, you can signal **success**, **start**, and **failure** events from
  3. your systems.
  4. ## General Notes
  5. All ping endpoints support:
  6. * HTTP and HTTPS
  7. * HTTP 1.0, HTTP 1.1 and HTTP 2
  8. * IPv4 and IPv6
  9. * HEAD, GET, and POST requests methods. The HTTP POST requests
  10. can optionally include diagnostic information in the request body.
  11. If the request body looks like a UTF-8 string, SITE_NAME stores the request body
  12. (limited to the first 10KB for each received ping).
  13. Successful responses will have the "200 OK" HTTP response status code and a short
  14. "OK" string in the response body.
  15. ## UUIDs and Slugs
  16. Each Pinging API request needs to uniquely identify a check.
  17. SITE_NAME supports two ways of identifying a check: by check's UUID,
  18. or by a combination of project's Ping Key and check's slug.
  19. **Check's UUID** is automatically assigned when the check is created. It is
  20. immutable. You cannot replace the automatically assigned UUID with a manually
  21. chosen one. When you delete a check, you also lose its UUID and cannot get it back.
  22. You can look up UUIDs of your checks in web UI or via [Management API](../api/) calls.
  23. **Check's slug** is derived from check's name using Django's
  24. [slugify](https://docs.djangoproject.com/en/3.2/ref/utils/#django.utils.text.slugify)
  25. function. It applies the following transformations:
  26. * Convert to ASCII.
  27. * Convert to lowercase.
  28. * Remove characters that aren't alphanumerics, underscores, hyphens, or whitespace.
  29. * Replace any whitespace or repeated hyphens with single hyphens.
  30. * Remove leading and trailing whitespace, hyphens, and underscores.
  31. For example, if check's name is "Database Backup", its slug is `database-backup`.
  32. Check's slug **can change**. SITE_NAME updates check's slug whenever its name changes.
  33. Check's slug is **not guaranteed to be unique**. If multiple checks in the project
  34. have the same name, they also have the same slug. If you make a Pinging API
  35. request using a non-unique slug, SITE_NAME will return the "409 Conflict" HTTP status
  36. code and ignore the request.
  37. ## Endpoints
  38. Endpoint Name | Endpoint Address
  39. ------------------------------------------------------------|-------
  40. [Success (UUID)](#success-uuid) | `PING_ENDPOINT<uuid>`
  41. [Start (UUID)](#start-uuid) | `PING_ENDPOINT<uuid>/start`
  42. [Failure (UUID)](#fail-uuid) | `PING_ENDPOINT<uuid>/fail`
  43. [Report script's exit status (UUID)](#exitcode-uuid) | `PING_ENDPOINT<uuid>/<exit-status>`
  44. [Success (slug)](#success-slug) | `PING_ENDPOINT<ping-key>/<slug>`
  45. [Start (slug)](#start-slug) | `PING_ENDPOINT<ping-key>/<slug>/start`
  46. [Failure (slug)](#fail-slug) | `PING_ENDPOINT<ping-key>/<slug>/fail`
  47. [Report script's exit status (slug)](#exitcode-slug) | `PING_ENDPOINT<ping-key>/<slug>/<exit-status>`
  48. ## Send a "success" Signal Using UUID {: #success-uuid .rule }
  49. ```text
  50. HEAD|GET|POST PING_ENDPOINT<uuid>
  51. ```
  52. Signals to SITE_NAME that the job has completed successfully (or,
  53. a continuously running process is still running and healthy).
  54. SITE_NAME identifies the check by the UUID value included in the URL.
  55. ### Response Codes
  56. 200 OK
  57. : The request succeeded.
  58. 404 not found
  59. : Could not find a check with the specified UUID.
  60. **Example**
  61. ```http
  62. GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278 HTTP/1.0
  63. Host: hc-ping.com
  64. ```
  65. ```http
  66. HTTP/1.1 200 OK
  67. Server: nginx
  68. Date: Wed, 29 Jan 2020 09:58:23 GMT
  69. Content-Type: text/plain; charset=utf-8
  70. Content-Length: 2
  71. Connection: close
  72. Access-Control-Allow-Origin: *
  73. OK
  74. ```
  75. ## Send a "start" Signal Using UUID {: #start-uuid .rule }
  76. ```text
  77. HEAD|GET|POST PING_ENDPOINT<uuid>/start
  78. ```
  79. Sends a "job has started!" message to SITE_NAME. Sending a "start" signal is optional,
  80. but it enables a few extra features:
  81. * SITE_NAME will measure and display job execution times
  82. * SITE_NAME will detect if the job runs longer than its configured grace time
  83. SITE_NAME identifies the check by the UUID value included in the URL.
  84. ### Response Codes
  85. 200 OK
  86. : The request succeeded.
  87. 404 not found
  88. : Could not find a check with the specified UUID.
  89. **Example**
  90. ```http
  91. GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/start HTTP/1.0
  92. Host: hc-ping.com
  93. ```
  94. ```http
  95. HTTP/1.1 200 OK
  96. Server: nginx
  97. Date: Wed, 29 Jan 2020 09:58:23 GMT
  98. Content-Type: text/plain; charset=utf-8
  99. Content-Length: 2
  100. Connection: close
  101. Access-Control-Allow-Origin: *
  102. OK
  103. ```
  104. ## Send a "failure" Signal Using UUID {: #fail-uuid .rule }
  105. ```text
  106. HEAD|GET|POST PING_ENDPOINT<uuid>/fail
  107. ```
  108. Signals to SITE_NAME that the job has failed. Actively signaling a failure
  109. minimizes the delay from your monitored service failing to you receiving an alert.
  110. SITE_NAME identifies the check by the UUID value included in the URL.
  111. ### Response Codes
  112. 200 OK
  113. : The request succeeded.
  114. 404 not found
  115. : Could not find a check with the specified UUID.
  116. **Example**
  117. ```http
  118. GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/fail HTTP/1.0
  119. Host: hc-ping.com
  120. ```
  121. ```http
  122. HTTP/1.1 200 OK
  123. Server: nginx
  124. Date: Wed, 29 Jan 2020 09:58:23 GMT
  125. Content-Type: text/plain; charset=utf-8
  126. Content-Length: 2
  127. Connection: close
  128. Access-Control-Allow-Origin: *
  129. OK
  130. ```
  131. ## Report Script's Exit Status (Using UUID) {: #exitcode-uuid .rule }
  132. ```text
  133. HEAD|GET|POST PING_ENDPOINT<uuid>/<exit-status>
  134. ```
  135. Sends a success or failure signal depending on the exit status
  136. included in the URL. The exit status is a 0-255 integer. SITE_NAME
  137. interprets 0 as success and all other values as failure.
  138. SITE_NAME identifies the check by the UUID value included in the URL.
  139. ### Response Codes
  140. 200 OK
  141. : The request succeeded.
  142. 400 invalid url format
  143. : The URL does not match the expected format.
  144. 404 not found
  145. : Could not find a check with the specified UUID.
  146. **Example**
  147. ```http
  148. GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/1 HTTP/1.0
  149. Host: hc-ping.com
  150. ```
  151. ```http
  152. HTTP/1.1 200 OK
  153. Server: nginx
  154. Date: Wed, 29 Jan 2020 09:58:23 GMT
  155. Content-Type: text/plain; charset=utf-8
  156. Content-Length: 2
  157. Connection: close
  158. Access-Control-Allow-Origin: *
  159. OK
  160. ```
  161. ## Send a "success" Signal (Using Slug) {: #success-slug .rule }
  162. ```text
  163. HEAD|GET|POST PING_ENDPOINT<ping-key>/<slug>
  164. ```
  165. Signals to SITE_NAME that the job has completed successfully (or,
  166. a continuously running process is still running and healthy).
  167. SITE_NAME identifies the check by project's ping key and check's slug
  168. included in the URL.
  169. ### Response Codes
  170. 200 OK
  171. : The request succeeded.
  172. 404 not found
  173. : Could not find a check with the specified ping key and slug combination.
  174. 409 ambiguous slug
  175. : Ambiguous, the slug matched multiple checks.
  176. **Example**
  177. ```http
  178. GET /fqOOd6-F4MMNuCEnzTU01w/database-backup HTTP/1.0
  179. Host: hc-ping.com
  180. ```
  181. ```http
  182. HTTP/1.1 200 OK
  183. Server: nginx
  184. Date: Wed, 29 Jan 2020 09:58:23 GMT
  185. Content-Type: text/plain; charset=utf-8
  186. Content-Length: 2
  187. Connection: close
  188. Access-Control-Allow-Origin: *
  189. OK
  190. ```
  191. ## Send a "start" Signal (Using Slug) {: #start-slug .rule }
  192. ```text
  193. HEAD|GET|POST PING_ENDPOINT<ping-key>/<slug>/start
  194. ```
  195. Sends a "job has started!" message to SITE_NAME. Sending a "start" signal is
  196. optional, but it enables a few extra features:
  197. * SITE_NAME will measure and display job execution times
  198. * SITE_NAME will detect if the job runs longer than its configured grace time
  199. SITE_NAME identifies the check by project's ping key and check's slug
  200. included in the URL.
  201. ### Response Codes
  202. 200 OK
  203. : The request succeeded.
  204. 404 not found
  205. : Could not find a check with the specified ping key and slug combination.
  206. 409 ambiguous slug
  207. : Ambiguous, the slug matched multiple checks.
  208. **Example**
  209. ```http
  210. GET /fqOOd6-F4MMNuCEnzTU01w/database-backup/start HTTP/1.0
  211. Host: hc-ping.com
  212. ```
  213. ```http
  214. HTTP/1.1 200 OK
  215. Server: nginx
  216. Date: Wed, 29 Jan 2020 09:58:23 GMT
  217. Content-Type: text/plain; charset=utf-8
  218. Content-Length: 2
  219. Connection: close
  220. Access-Control-Allow-Origin: *
  221. OK
  222. ```
  223. ## Send a "failure" Signal (Using slug) {: #fail-slug .rule }
  224. ```text
  225. HEAD|GET|POST PING_ENDPOINT<ping-key/<slug>/fail
  226. ```
  227. Signals to SITE_NAME that the job has failed. Actively signaling a failure
  228. minimizes the delay from your monitored service failing to you receiving an alert.
  229. SITE_NAME identifies the check by project's ping key and check's slug
  230. included in the URL.
  231. ### Response Codes
  232. 200 OK
  233. : The request succeeded.
  234. 404 not found
  235. : Could not find a check with the specified ping key and slug combination.
  236. 409 ambiguous slug
  237. : Ambiguous, the slug matched multiple checks.
  238. **Example**
  239. ```http
  240. GET /fqOOd6-F4MMNuCEnzTU01w/database-backup/fail HTTP/1.0
  241. Host: hc-ping.com
  242. ```
  243. ```http
  244. HTTP/1.1 200 OK
  245. Server: nginx
  246. Date: Wed, 29 Jan 2020 09:58:23 GMT
  247. Content-Type: text/plain; charset=utf-8
  248. Content-Length: 2
  249. Connection: close
  250. Access-Control-Allow-Origin: *
  251. OK
  252. ```
  253. ## Report Script's Exit Status (Using Slug) {: #exitcode-slug .rule }
  254. ```text
  255. HEAD|GET|POST PING_ENDPOINT<ping-key>/<slug>/<exit-status>
  256. ```
  257. Sends a success or failure signal depending on the exit status
  258. included in the URL. The exit status is a 0-255 integer. SITE_NAME
  259. interprets 0 as success and all other values as failure.
  260. SITE_NAME identifies the check by project's ping key and check's slug
  261. included in the URL.
  262. ### Response Codes
  263. 200 OK
  264. : The request succeeded.
  265. 400 invalid url format
  266. : The URL does not match the expected format.
  267. 404 not found
  268. : Could not find a check with the specified ping key and slug combination.
  269. 409 ambiguous slug
  270. : Ambiguous, the slug matched multiple checks.
  271. **Example**
  272. ```http
  273. GET /fqOOd6-F4MMNuCEnzTU01w/database-backup/1 HTTP/1.0
  274. Host: hc-ping.com
  275. ```
  276. ```http
  277. HTTP/1.1 200 OK
  278. Server: nginx
  279. Date: Wed, 29 Jan 2020 09:58:23 GMT
  280. Content-Type: text/plain; charset=utf-8
  281. Content-Length: 2
  282. Connection: close
  283. Access-Control-Allow-Origin: *
  284. OK
  285. ```