Skip to content

Commit

Permalink
Document check header and method
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Aug 17, 2017
1 parent 9757867 commit a6bf5b6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
8 changes: 8 additions & 0 deletions website/source/api/json-jobs.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Below is the JSON representation of the job outputed by `$ nomad init`:
"Type": "tcp",
"Command": "",
"Args": null,
"Header": {},
"Method": "",
"Path": "",
"Protocol": "",
"PortLabel": "",
Expand Down Expand Up @@ -344,12 +346,18 @@ The `Task` object supports the following keys:

- `Name`: The name of the health check.

- `Header`: Headers for HTTP checks. Should be an object where the
values are an array of values. Headers will be written once for each
value.

- `Interval`: This indicates the frequency of the health checks that
Consul will perform.

- `Timeout`: This indicates how long Consul will wait for a health
check query to succeed.

- `Method`: The HTTP method to use for HTTP checks. Defaults to GET.

- `Path`: The path of the HTTP endpoint which Consul will query to query
the health of a service if the type of the check is `http`. Nomad
will add the IP of the service and the port, users are only required
Expand Down
32 changes: 30 additions & 2 deletions website/source/docs/job-specification/service.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ scripts.
that Consul will perform. This is specified using a label suffix like "30s"
or "1h". This must be greater than or equal to "1s"

- `method` `(string: "GET")` - Specifies the HTTP method to use for HTTP
checks.

- `name` `(string: "service: <name> check")` - Specifies the name of the health
check.

Expand Down Expand Up @@ -159,6 +162,27 @@ scripts.
- `tls_skip_verify` `(bool: false)` - Skip verifying TLS certificates for HTTPS
checks. Requires Consul >= 0.7.2.

#### `header` Stanza

HTTP checks may include a `header` stanza to set HTTP headers. The `header`
stanza parameters have lists of strings as values. Multiple values will cause
the header to be set multiple times, once for each value.

```hcl
service {
check {
type = "http"
port = "lb"
path = "/_healthz"
interval = "5s"
timeout = "2s"
header {
Authorization = ["Basic ZWxhc3RpYzpjaGFuZ2VtZQ=="]
}
}
}
```


## `service` Examples

Expand Down Expand Up @@ -232,8 +256,8 @@ argument provided as a value to the `args` array.

This example shows a service with an HTTP health check. This will query the
service on the IP and port registered with Nomad at `/_healthz` every 5 seconds,
giving the service a maximum of 2 seconds to return a response. Any non-2xx code
is considered a failure.
giving the service a maximum of 2 seconds to return a response, and include an
Authorization header. Any non-2xx code is considered a failure.

```hcl
service {
Expand All @@ -243,6 +267,9 @@ service {
path = "/_healthz"
interval = "5s"
timeout = "2s"
header {
Authorization = ["Basic ZWxhc3RpYzpjaGFuZ2VtZQ=="]
}
}
}
```
Expand All @@ -269,6 +296,7 @@ service {
path = "/_healthz"
interval = "5s"
timeout = "2s"
method = "POST"
}
check {
Expand Down

0 comments on commit a6bf5b6

Please sign in to comment.