epazote.yml ​
Epazote uses a YAML configuration file. Below are the available options:
services:
example-service:
every: 5m
url: https://example.com
method: GET
follow_redirects: true
max_bytes: 1024
timeout: 10s
expect:
status: 200
header:
Content-Type: text/html
every
: Specifies how often the service is checked. Supports s (seconds), m (minutes), h (hours), and d (days).
url
: The URL to check. (test
can be used instead of url
to check the exit status of a command.)
method
: The HTTP method to use when checking the URL. (default: GET)
INFO
You can use any of the following methods:
CONNECT
DELETE
GET
HEAD
OPTIONS
PATCH
POST
PUT
TRACE
follow_redirects
: Follow HTTP redirects. (default: false)
max_bytes
: The maximum number of bytes to read from the response. (default: No limit)
TIP
if you want to search for specific content in the response, you can use the max_bytes
option to limit the number of bytes read from the response.
For example, if you want to search for the word "success" in the response, you can set max_bytes
to a value that you know will contain the word "success":
services:
example-service:
every: 5m
url: http://example.com
max_bytes: 1024
expect:
status: 200
body: success
if no max_bytes
is set, the entire response will be read in chunks until the end of the response and stop reading when the word "success" is found.
timeout
: The maximum time to wait for a response. (default: 5s)
expect
: Defines expected responses from the service.
expect:
status: 200
header:
Content-Type: "application/json"
body: "success"
if_not:
cmd: "sudo systemctl restart example-service"
status
: Expected HTTP status code or when usingtest
instead ofURL
the exit status code.header
: Expected response headers.body
: Expected response body.if_not
: Actions to take if expectations fail.
if_not
: Defines actions to take if the check fails
if_not:
stop: 2
cmd: "systemctl restart example-service"
http: "http://alert-service/restart"
stop
: Number of times to run the cmd or http then it will not call the cmd or http.cmd
: Command to run if the check fails.http
: HTTP endpoint to call if the check fails.
Body options (json,form,text) ​
If you want to submit data using for example the POST method, you have three options:
json
- Sends the data as JSONform
- Sends the data as a formtext
- Sends the data as text
The headers are set automatically based on the body type, but can be changed if needed using the option
headers
.
Example submitting data as JSON:
services:
example-service:
every: 5m
url: http://example.com
method: POST
body:
json:
key: value
Example submitting data as a form:
services:
example-service:
every: 5m
url: http://example.com
method: POST
body:
form:
key: value
Example submitting data as text:
services:
example-service:
every: 5m
url: http://example.com
method: POST
body: "Hello World!"
headers:
content-type: text/plain
TIP
You can override the default headers by adding a headers
key.
For example in the case of sending a text body, you can set the content-type to text/plain
, together with other custom headers:
headers:
content-type: text/plain
X-Custom-Header: TestValue
Body regular expressions ​
You can use regular expressions to match the body of the response. For example, to match the word "success" in the body:
services:
example-service:
every: 5m
url: http://example.com
expect:
status: 200
body: success
for more complex regular expressions, preix the body with r"<your regex>"
:
services:
example-service:
every: 5m
url: http://example.com
expect:
status: 200
body: r"success|ok"
Test command ​
Instead of using a URL, you can use the test
key to check the exit status of a command:
services:
example-service:
every: 5m
test: "pgrep -x httpd"
expect:
status: 0
test
: is a shell command that will be executed status
: is the expected exit status of the command
It can be used also with if_not
and perform actions if the command fails:
services:
example-service:
every: 5m
test: pgrep -x httpd
expect:
status: 0
if_not:
cmd: sudo systemctl restart httpd