diff --git a/canary-checker/docs/reference/http.mdx b/canary-checker/docs/reference/http.mdx
index bdf0ae40..c7dd66a0 100644
--- a/canary-checker/docs/reference/http.mdx
+++ b/canary-checker/docs/reference/http.mdx
@@ -2,13 +2,10 @@
title: HTTP
---
-
# HTTP
This check performs queries on HTTP endpoints, and HTTP Namespaces to monitor their activity.
-
-
```yaml title=http-check.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
@@ -24,48 +21,48 @@ spec:
maxSSLExpiry: 7
```
-| Field | Description | Scheme | Required |
-| ----- | ----------- | ------ | -------- |
-| **`url`** | | *string* | Yes |
-| `endpoint` | Deprecated, Use `url` instread | *string* | |
-| `method` | HTTP Request method, default to `GET` | *string* | |
-| `headers` | Header fields to be used in the query | [[]*EnvVar*](../../concepts/authentication/#envvar) | |
-| `body` | Request Body Contents | *string* | |
-| `templateBody` | If true the `body` field will be templated using go templates these [variables](#templateVariables) will be available | boo; | |
-| `responseCodes` | Expected response codes for the HTTP Request. | *[]int* | |
-| `responseContent` | Exact response content expected to be returned by the endpoint. | *string* | |
-| `thresholdMillis` | Maximum duration in milliseconds for the HTTP request. It will fail the check if it takes longer. | *int* | |
-| `maxSSLExpiry` | Maximum number of days until the SSL Certificate expires. | *int* | |
-| **`name`** | Name of the check, must be unique within the canary | `string` | Yes |
-| `description` | Description for the check | `string` | |
-| `icon` | Icon for overwriting default icon on the dashboard | `string` | |
-| `labels` | Labels for check | `map[string]string` | |
-| `test` | Evaluate whether a check is healthy | [`Expression`](../concepts/health-evaluation) | |
-| `display` | Expression to change the formatting of the display | [`Expression`](../concepts/display-formatting) | |
-| `transform` | Transform data from a check into multiple individual checks | [`Expression`](../concepts/transforms) | |
-| `metrics` | Metrics to export from | [`[]Metrics`](../concepts/metrics-exporter) | |
-| **Connection** | | | |
-| `connection` | Path of existing connection e.g. `connection://http/instance`
Mutually exclusive with `username`, `password`
| *Connection* | |
-| `username` | Mutually exclusive with `connection` | *EnvVar* | |
-| `password` | Mutually exclusive with `connection` | *EnvVar* | |
-| **`url`** | HTTP URL, if a URL is specified on both the connection and check, the url on the check takes precedence. | *string* | Yes |
-| `ntlm` | When true will do authentication using NTLM v1 protocol | *bool* | |
-| `ntlmv2` | When true will do authentication using NTLM v2 protocol | *bool* | |
+| Field | Description | Scheme | Required | Templatable |
+| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | -------- | ----------- |
+| **`url`** | | _string_ | `true` | `true` |
+| `endpoint` | _(Deprecated)_ Use `url` instread | _string_ | | |
+| `method` | HTTP Request method, default to `GET` | _string_ | | |
+| `headers` | Header fields to be used in the query | [[]_EnvVar_](../../concepts/authentication/#envvar) | | |
+| `body` | Request Body Contents | _string_ | | `true` |
+| `templateBody` | _(Deprecated)_ If true the `body` field will be templated using go templates these [variables](#templateVariables) will be available | boo; | | |
+| `responseCodes` | Expected response codes for the HTTP Request. | _[]int_ | | |
+| `responseContent` | Exact response content expected to be returned by the endpoint. | _string_ | | |
+| `thresholdMillis` | Maximum duration in milliseconds for the HTTP request. It will fail the check if it takes longer. | _int_ | | |
+| `maxSSLExpiry` | Maximum number of days until the SSL Certificate expires. | _int_ | | |
+| **`name`** | Name of the check, must be unique within the canary | `string` | `true` | |
+| `description` | Description for the check | `string` | | |
+| `icon` | Icon for overwriting default icon on the dashboard | `string` | | |
+| `labels` | Labels for check | `map[string]string` | | |
+| `test` | Evaluate whether a check is healthy | [`Expression`](../concepts/health-evaluation) | | |
+| `display` | Expression to change the formatting of the display | [`Expression`](../concepts/display-formatting) | | |
+| `transform` | Transform data from a check into multiple individual checks | [`Expression`](../concepts/transforms) | | |
+| `metrics` | Metrics to export from | [`[]Metrics`](../concepts/metrics-exporter) | | |
+| `env` | Specify env vars that can be accessed during templating of the URL and the body | [[]_EnvVar_](../../concepts/authentication/#envvar) | | |
+| **Connection** | | | | |
+| `connection` | Path of existing connection e.g. `connection://http/instance`
Mutually exclusive with `username`, `password`
| _Connection_ | | |
+| `username` | Mutually exclusive with `connection` | _EnvVar_ | | |
+| `password` | Mutually exclusive with `connection` | _EnvVar_ | | |
+| **`url`** | HTTP URL, if a URL is specified on both the connection and check, the url on the check takes precedence. | _string_ | `true` | |
+| `ntlm` | When true will do authentication using NTLM v1 protocol | _bool_ | | |
+| `ntlmv2` | When true will do authentication using NTLM v2 protocol | _bool_ | | |
### Result Variables
Result variables can be used in `test`, `display` and `transform` [expressions](../concepts/expressions)
-| Name | Description | Scheme |
-| --------- | ------------------------------------------------------------ | ------------------- |
-| `code` | HTTP response code | *int* |
-| `headers` | HTTP response headers | *map[string]string* |
-| `elapsed` | HTTP Request duration | *time.Duration* |
-| `sslAge` | Time until SSL certificate expires | *time.Duration* |
-| `content` | HTTP Response body | string |
+| Name | Description | Scheme |
+| --------- | --------------------------------------------------------------------------- | ------------------- |
+| `code` | HTTP response code | _int_ |
+| `headers` | HTTP response headers | _map[string]string_ |
+| `elapsed` | HTTP Request duration | _time.Duration_ |
+| `sslAge` | Time until SSL certificate expires | _time.Duration_ |
+| `content` | HTTP Response body | string |
| `json` | If `Content-Type=application/json` response body converted into JSON object | `JSON` |
-
The above canary (`http-check.yaml`) is functionally equivalent to `http-check-expr.yaml` below
```yaml title=http-check-expr.yaml
@@ -84,17 +81,47 @@ spec:
### Template Body Variables
-| Name | Scheme |
-| ----- | ------ |
-| `metadata.name` | string |
-| `metadata.metadata.namespace` | *string* |
-| `metadata.labels` | *map[string]string* |
+| Name | Scheme |
+| ----------------------------- | ------------------- |
+| `metadata.name` | string |
+| `metadata.metadata.namespace` | _string_ |
+| `metadata.labels` | _map[string]string_ |
+| `{fields from []env}` | any |
+
+Variables defined in `env` will be available to template with the name that's configured on the spec.
+Eg: In the following spec, the vars `my_secret_path` and `my_secret_var`, defined in `env`, are available during templating.
+
+```yaml title=http-check.yaml
+apiVersion: canaries.flanksource.com/v1
+kind: Canary
+metadata:
+ name: http-check
+spec:
+ interval: 30
+ http:
+ - name: http pass response 200 status code
+ endpoint: https://example.com/{{.my_secret_path}}
+ body: |
+ {
+ "secret": {{.my_secret_var}}
+ }
+ env:
+ - name: my_secret_var
+ valueFrom:
+ secretKeyRef:
+ name: the-secret
+ key: key
+ - name: my_secret_path
+ value: secret_path
+```
+
+**Read**: [Escaping variables](../scripting/gotemplate#escaping)
## Metrics
-| **HTTP Check Metrics** | | |
-| ------------------------------------------------------------ | ------- | --------------------------------------- |
+| **HTTP Check Metrics** | | |
+| ------------------------------------------------------------- | ------- | --------------------------------------- |
| `canary_check_http_response_status{status, statusClass, url}` | Counter | Response code counter for each endpoint |
-| `canary_check_http_ssl_expiry{url}` | Guage | |
+| `canary_check_http_ssl_expiry{url}` | Guage | |
Status class is one of `1xx`, `2xx`, `3xx`, `4xx`, `5xx`
diff --git a/canary-checker/docs/scripting/gotemplate.md b/canary-checker/docs/scripting/gotemplate.md
index 17cf5c0b..ba6629a6 100644
--- a/canary-checker/docs/scripting/gotemplate.md
+++ b/canary-checker/docs/scripting/gotemplate.md
@@ -17,6 +17,21 @@ spec:
```
+## Escaping
+
+In case you might need to pass in a template variable without templating it, then you can put the template inside a string.
+Example:
+
+```
+{{ .secret }}
+```
+
+To send `{{ .secret }}` as it is do this
+
+```
+{{`{{ .secret }}`}}
+```
+
## Encoding
### Encode