Skip to content
Snippets Groups Projects
Commit 72c450dc authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check_http update docs

parent 1dff832d
No related branches found
No related tags found
1 merge request!167check_http update docs
...@@ -34,9 +34,9 @@ Additionally you can verify the response by ...@@ -34,9 +34,9 @@ Additionally you can verify the response by
SYNTAX: SYNTAX:
$_self [-h] $_self [-h]
$_self [-m METHOD] -u URL [-c PARAMS]\\ $_self [-m METHOD] -u URL [-c PARAMS]\\
[-b REGEX] [-j FILTER] [-n REGEX] \\ [-j FILTER] \\
[-r REGEX] \\
[-s STATUSCODE] \\ [-s STATUSCODE] \\
[-b REGEX] [-n REGEX] [-r REGEX] \\
[-l LABEL] [-l LABEL]
OPTIONS: OPTIONS:
...@@ -51,17 +51,19 @@ PARAMETERS: ...@@ -51,17 +51,19 @@ PARAMETERS:
-c PARAMS additional curl params; curl will be executed -c PARAMS additional curl params; curl will be executed
with '[PARAMS] -si -X [METHOD] --connect-timeout 10 [URL]' with '[PARAMS] -si -X [METHOD] --connect-timeout 10 [URL]'
Filtering:
-j JQ-FILTER for JSON Response: filter response body by jq
What to check: What to check:
-s STATUSCODE exact Statuscode to check; 3 digits; by default critical -s STATUSCODE exact Statuscode to check; 3 digits; by default critical
is a statuscode greater equal 400 is a statuscode greater equal 400
-r REGEX Regex must match in http response header -r REGEX Regex must match in http response header
-j JQ-FILTER for JSON Response: filter data by a jq
-b REGEX Regex must match in response body -b REGEX Regex must match in response body
-n REGEX Regex must NOT match in response body -n REGEX Regex must NOT match in response body
Output: Output:
-l LABEL set a custom label; default: METHOD + URL eg. -l LABEL set a custom label; default: METHOD + URL eg.
"GET https://example.com/status" "GET https://example.com/status (200)"
EXAMPLES: EXAMPLES:
......
...@@ -7,7 +7,8 @@ Additionally you can verify the response. ...@@ -7,7 +7,8 @@ Additionally you can verify the response.
## Requirements ## Requirements
* `curl` binary * ``curl`` - a tool for transferring data from or to a server
* ``jq`` - commandline JSON processor - optional: for param ``-j``
## Syntax ## Syntax
...@@ -32,10 +33,10 @@ Additionally you can verify the response by ...@@ -32,10 +33,10 @@ Additionally you can verify the response by
SYNTAX: SYNTAX:
check_http [-h] check_http [-h]
check_http [-m METHOD] -u URL \ check_http [-m METHOD] -u URL [-c PARAMS]\
[-b REGEX] [-j FILTER] [-n REGEX] \ [-j FILTER] \
[-r REGEX] \
[-s STATUSCODE] \ [-s STATUSCODE] \
[-b REGEX] [-n REGEX] [-r REGEX] \
[-l LABEL] [-l LABEL]
OPTIONS: OPTIONS:
...@@ -50,17 +51,19 @@ PARAMETERS: ...@@ -50,17 +51,19 @@ PARAMETERS:
-c PARAMS additional curl params; curl will be executed -c PARAMS additional curl params; curl will be executed
with '[PARAMS] -si -X [METHOD] --connect-timeout 10 [URL]' with '[PARAMS] -si -X [METHOD] --connect-timeout 10 [URL]'
Filtering:
-j JQ-FILTER for JSON Response: filter response body by jq
What to check: What to check:
-s STATUSCODE exact Statuscode to check; 3 digits; by default critical -s STATUSCODE exact Statuscode to check; 3 digits; by default critical
is a statuscode greater equal 400 is a statuscode greater equal 400
-r REGEX Regex must match in http response header -r REGEX Regex must match in http response header
-j JQ-FILTER for JSON Response: filter data by a jq
-b REGEX Regex must match in response body -b REGEX Regex must match in response body
-n REGEX Regex must NOT match in response body -n REGEX Regex must NOT match in response body
Output: Output:
-l LABEL set a custom label; default: METHOD + URL eg. -l LABEL set a custom label; default: METHOD + URL eg.
"GET https://example.com/status" "GET https://example.com/status (200)"
EXAMPLES: EXAMPLES:
...@@ -137,3 +140,41 @@ Or you can check a flag file that must be absent. ...@@ -137,3 +140,41 @@ Or you can check a flag file that must be absent.
You can verify if the response matches a given regex. You can search in the response header with ``-r REGEX`` and in the response body with ``-b REGEX``. You can verify if the response matches a given regex. You can search in the response header with ``-r REGEX`` and in the response body with ``-b REGEX``.
``check_http -u [URL] -b "contact"`` will resppns OK if the status code is not an error (lower 400) and the word "contact" is found in response body. ``check_http -u [URL] -b "contact"`` will resppns OK if the status code is not an error (lower 400) and the word "contact" is found in response body.
### JSON filtering
With the parameter ``-j JQ-FILTER`` the jq command will be applied on the response body.
Whenever you add ``-j`` a search in the body with params ``-b REGEX`` and ``-n REGEX`` won't be applied to the complete response body but on the result after filtering with jq. So you can build API checks that respond a json structure.
Keycloak responds on its health url
```txt
$ curl -k https://keycloak.example.com:8443/health
{
"status": "UP",
"checks": [
]
}
```
First test a filter string on command line
``curl -k https://keycloak.example.com:8443/health | jq ".status"``
Its result is just "UP" - all other json stuff is blown away.
This filter we put into the ``-j`` param:
`` ./check_http -u "https://keycloak.example.com:8443/health" -j ".status" -b "UP" `` returns
```txt
OK: GET https://keycloak.example.com:8443/health (200)
Found:
- jq filter [.status] matches.
- Http status is a 2xx OK [200];
- [UP] was found in body;
Hints:
Content aufter jq filter: "UP"
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment