Skip to content

Commit a6bf5b6

Browse files
committed
Document check header and method
1 parent 9757867 commit a6bf5b6

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

website/source/api/json-jobs.html.md

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Below is the JSON representation of the job outputed by `$ nomad init`:
5858
"Type": "tcp",
5959
"Command": "",
6060
"Args": null,
61+
"Header": {},
62+
"Method": "",
6163
"Path": "",
6264
"Protocol": "",
6365
"PortLabel": "",
@@ -344,12 +346,18 @@ The `Task` object supports the following keys:
344346

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

349+
- `Header`: Headers for HTTP checks. Should be an object where the
350+
values are an array of values. Headers will be written once for each
351+
value.
352+
347353
- `Interval`: This indicates the frequency of the health checks that
348354
Consul will perform.
349355

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

359+
- `Method`: The HTTP method to use for HTTP checks. Defaults to GET.
360+
353361
- `Path`: The path of the HTTP endpoint which Consul will query to query
354362
the health of a service if the type of the check is `http`. Nomad
355363
will add the IP of the service and the port, users are only required

website/source/docs/job-specification/service.html.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ scripts.
130130
that Consul will perform. This is specified using a label suffix like "30s"
131131
or "1h". This must be greater than or equal to "1s"
132132

133+
- `method` `(string: "GET")` - Specifies the HTTP method to use for HTTP
134+
checks.
135+
133136
- `name` `(string: "service: <name> check")` - Specifies the name of the health
134137
check.
135138

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

165+
#### `header` Stanza
166+
167+
HTTP checks may include a `header` stanza to set HTTP headers. The `header`
168+
stanza parameters have lists of strings as values. Multiple values will cause
169+
the header to be set multiple times, once for each value.
170+
171+
```hcl
172+
service {
173+
check {
174+
type = "http"
175+
port = "lb"
176+
path = "/_healthz"
177+
interval = "5s"
178+
timeout = "2s"
179+
header {
180+
Authorization = ["Basic ZWxhc3RpYzpjaGFuZ2VtZQ=="]
181+
}
182+
}
183+
}
184+
```
185+
162186

163187
## `service` Examples
164188

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

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

238262
```hcl
239263
service {
@@ -243,6 +267,9 @@ service {
243267
path = "/_healthz"
244268
interval = "5s"
245269
timeout = "2s"
270+
header {
271+
Authorization = ["Basic ZWxhc3RpYzpjaGFuZ2VtZQ=="]
272+
}
246273
}
247274
}
248275
```
@@ -269,6 +296,7 @@ service {
269296
path = "/_healthz"
270297
interval = "5s"
271298
timeout = "2s"
299+
method = "POST"
272300
}
273301
274302
check {

0 commit comments

Comments
 (0)