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.

65 lines
2.0 KiB

  1. # Attaching Logs
  2. SITE_NAME ping endpoints accept HTTP HEAD, GET and POST request methods.
  3. When using HTTP POST, **you can include an arbitrary payload in the request body**.
  4. If the request body looks like a UTF-8 string, SITE_NAME will log the
  5. first 10 kilobytes (10 000 bytes) of the request body, so that you can inspect
  6. it later.
  7. ## Logging Command Output
  8. In this example, we run `certbot renew`, capture its output (both the stdout
  9. and stderr streams), and submit the captured output to SITE_NAME:
  10. ```bash
  11. #!/bin/sh
  12. m=$(/usr/bin/certbot renew 2>&1)
  13. curl -fsS -m 10 --retry 5 --data-raw "$m" PING_URL
  14. ```
  15. ## In Combination with the `/fail` and `/{exit-status}` Endpoints
  16. We can extend the previous example and signal either success or failure
  17. depending on the exit code:
  18. ```bash
  19. #!/bin/sh
  20. m=$(/usr/bin/certbot renew 2>&1)
  21. curl -fsS -m 10 --retry 5 --data-raw "$m" PING_URL/$?
  22. ```
  23. ## Using Runitor
  24. [Runitor](https://github.com/bdd/runitor) is a third party utility that runs the
  25. supplied command, captures its output and reports to SITE_NAME.
  26. It also measures the execution time and retries HTTP requests on transient errors.
  27. Best of all, the syntax is simple and clean:
  28. ```bash
  29. runitor -uuid your-uuid-here -- /usr/bin/certbot renew
  30. ```
  31. ## Handling More Than 10KB of Logs
  32. While SITE_NAME can store a small amount of logs in a pinch, it is not specifically
  33. designed for that. If you run into the issue of logs getting cut off, consider
  34. the following options:
  35. * See if the logs can be made less verbose. For example, if you have a batch job
  36. that outputs a line of text per item processed, perhaps it can output a summary with
  37. the totals instead.
  38. * If the important content is usually at the end, submit the **last 10KB** instead
  39. of the first. Here is an example that submits the last 10KB of `dmesg` output:
  40. ```bash
  41. #!/bin/sh
  42. m=$(dmesg | tail --bytes=10000)
  43. curl -fsS -m 10 --retry 5 --data-raw "$m" PING_URL
  44. ```
  45. * Finally, if it is critical to capture the entire log output,
  46. consider using a dedicated log aggregation service for capturing the logs.