Targets¶
The following example runs a check against Postman’s test site:
targets:
- name: Postman Echo
host: postman-echo.com
protocol: https
headers:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7
Accept: application/json
checks:
- name: forms
tags: [ forms ]
interval: 60s
session:
- name: query_params
path: /get
params: { p1: hello, p2: world }
method: get
timeout: 5s
rules:
- if:
- after: 1s
event: { policy: critical }
- after: 0.6s
event: { policy: warning, abort: false }
targets [array]¶
One or more services to be checked.
targets.name [string]¶
Each target has a name. This name should be short and descriptive as it will be used as an identifier
when generating events or sending metrics to integrations. For example, if the DataDog integration were
enabled, a metric named tacdog.postman_echo.forms.elapsed
would be generated and sent to DataDog.
targets.host [string]¶
The domain name or IP address of the service.
targets.protocol [string]¶
One of http
or https
. Will be used as the HTTP scheme. A value of https
also enables certificate
checking (invalid, missing, expired).
targets.headers [hash]¶
Any custom HTTP headers to be sent with the request.
targets.checks [array]¶
This section is where you define one or more checks to be run. Each check uses a single HTTP session, so cookies and headers are preserved between HTTP requests.
targets.checks.name [string]¶
Each check should be given a unique name. As with targets.name
, this value will be used as an identifier
in events and metrics and should be short but meaningful.
targets.checks.tags [hash]¶
Tags of the form name:value
which will be included with events and metrics.
targets.checks.interval [string | float | integer]¶
The interval between check runs. This can be expressed as in seconds, minutes, or hours (e.g. 30s
, 2m
,
0.5h
). The minimum interval is 30s
. Floats or integers are considered to be in seconds.
targets.checks.session [array]¶
This section represents the HTTP session. All requests contained within this section share a session, including HTTP headers and cookies.
targets.checks.session.name [string]¶
Each session should be given a unique name. This value will be used as an identifier in reported events and metrics and should be short but meaningful.
targets.checks.session.path [string]¶
The path part of the URL.
targets.checks.session.params¶
A hash of values to be passed as GET or POST parameters. This hash will be automatically be URL-encoded.
targets.checks.session.method [string]¶
One of GET, POST, PUT, DELETE, HEAD. The HTTP method to utilize in the request.
targets.checks.session.timeout [string | float | integer]¶
How long to wait for a response before triggering an event.
targets.checks.session.rules [array]¶
Rules are actions to take based on the HTTP response from the target. Different types of actions include triggering events or capturing data.
targets.checks.session.rules.if [array]¶
targets.checks.session.rules.if not [array]¶
The if
and if not
blocks control which rules will be run. if
can test against several conditionals:
before
,after
: test whether the response time is less- or greater-than a user-defined value (e.g. ‘5s’).status
: test the HTTP response code against a user-defined value (e.g. 404, 501, etc).
targets.checks.session.rules.event [hash]¶
This causes an event of a user-defined policy to be triggered.
The following event would cause the policy named critical
to be invoked.
event: { policy: critical }
By default, triggering an event causes the entire rule to be aborted. If you want to trigger an event but
continue processing rules, set the abort
key to false
:
event: { policy: warning, abort: false }
targets.checks.session.rules.capture [hash]¶
Captures are a more advanced option that are covered in detail here. For now, they are mentioned for completeness.
A capture
block allows you to capture values from the body of the target response. Captures are done
using one of JSONPath, JMESPath, regular expression, or CSS selector.
An example using JSONPath:
capture:
json: $.data.*
as: [ v1, v2 ]
The above JSONPath expression searches for an array of values and destructures them into the specified variables
defined in the as
key (v1
and v2
).
If there are more values than variables, extra values will be ignored.