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.

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