-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
535 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
1. Use an active, present tense voice | ||
2. Do not use any salesy or marketing terms, Do not use adverbs | ||
3. Use MDX formatting | ||
4. Do not use the first person, Use "you" or "your team" | ||
5. Do not use archaic language | ||
6. Do not use oxymorons | ||
7. Precede every command with an explanation of what the command does. After the command, provide additional details about the command, such as what the arguments do and why your reader is using them. | ||
8. Avoid pop culture references, gender assumptions, holidays, hemisphere seasons, and other exclusionary language | ||
9. Do not tell people how they feel | ||
10. Explicitly tell the user to create or open each file you’ll have them use. | ||
11. Like commands, always introduce a file or script by describing its general purpose, then explain any changes that the reader will be making in the file. Without these explanations, readers won’t be able to customize, update, or troubleshoot issues in the long run. | ||
12. If you’re asking the reader to write code, follow the same approach for commands: introduce the code block with a high-level explanation of what it does. Then show the code, and then call out any important details. | ||
13. Avoid adverbs and complex language | ||
14. Use markdown codeblocks with a language and a title | ||
15. Do not remove any "```" or "//highlight-next-line" text | ||
16. Do not use the term "this document", when referring to the system or product being documented always use "Mission Control" | ||
17. For examples using the following structure: | ||
Introduction of example | ||
Example Code | ||
This example: | ||
1. Using `field1` to perform A | ||
2. Using `field2` to perform B | ||
3. Achieves the result |
132 changes: 132 additions & 0 deletions
132
canary-checker/docs/concepts/expressions/_transform_fields.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<Fields rows={[ | ||
{ | ||
field: "start", | ||
description: "The time the check or event logically started (e.g if coming from an external source)", | ||
scheme: "time.Time", | ||
priority: 1, | ||
required: false | ||
}, | ||
{ | ||
field: "pass", | ||
description: "Set to true if the health check is passing", | ||
scheme: "bool", | ||
priority: 2, | ||
required: true | ||
}, | ||
{ | ||
field: "invalid", | ||
description: "Set to true if the check is not configured correctly, and can never pass", | ||
scheme: "bool", | ||
priority: 2, | ||
required: false | ||
}, | ||
{ | ||
field: "error", | ||
description: "An error message to be shown, if non-empty sets `pass: false` automatically", | ||
scheme: "string", | ||
priority: 1, | ||
required: false | ||
}, | ||
|
||
{ | ||
field: "deletedAt", | ||
description: "The time the check or event logically ended", | ||
scheme: "time.Time", | ||
priority: 1, | ||
required: false | ||
}, | ||
{ | ||
field: "duration", | ||
description: "Time in ms to use for the duration of the check", | ||
scheme: "int64", | ||
priority: 2, | ||
required: false | ||
}, | ||
|
||
{ | ||
field: "message", | ||
description: "Informational message to be shown to users", | ||
scheme: "string", | ||
priority: 1, | ||
required: false | ||
}, | ||
|
||
{ | ||
field: "name", | ||
description: "Name of the check to use, the name will be used to lookup existing checks to update", | ||
priority: 2, | ||
scheme: "string", | ||
required: true | ||
}, | ||
{ | ||
field: "namespace", | ||
description: null, | ||
priority: 1, | ||
scheme: "string", | ||
required: false | ||
}, | ||
{ | ||
field: "description", | ||
description: null, | ||
scheme: "string", | ||
required: false | ||
}, | ||
{ | ||
field: "type", | ||
description: null, | ||
scheme: "string", | ||
required: false | ||
}, | ||
{ | ||
field: "labels", | ||
priority: 1, | ||
description: null, | ||
scheme: "map[string]string", | ||
required: false | ||
}, | ||
|
||
{ | ||
field: "detail", | ||
description: null, | ||
scheme: "interface{}", | ||
required: false | ||
}, | ||
{ | ||
field: "data", | ||
description: null, | ||
scheme: "map[string]interface{}", | ||
required: false | ||
}, | ||
{ | ||
field: "metrics", | ||
description: "Add custom metrics to be exported", | ||
scheme: "[[]Metric](../metrics/custom-metrics#metric)", | ||
required: false | ||
}, | ||
{ | ||
field: "icon", | ||
description: null, | ||
priority: 1, | ||
scheme: "Icon", | ||
required: false | ||
}, | ||
|
||
{ | ||
field: "endpoint", | ||
description: null, | ||
scheme: "string", | ||
required: false | ||
}, | ||
{ | ||
field: "displayType", | ||
description: null, | ||
scheme: "string", | ||
required: false | ||
}, | ||
{ | ||
field: "transformDeleteStrategy", | ||
description: "How to handle checks that were returned in a previous transformation, but not in the current ", | ||
anyOf: ["MarkHealthy", "MarkUnhealthy", "Ignore"], | ||
required: false | ||
} | ||
]}/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
title: Webhook | ||
--- | ||
|
||
|
||
import TransformFields from '../concepts/expressions/_transform_fields.mdx' | ||
|
||
# <Icon name="webhook" /> Webhook | ||
|
||
Webhooks allow you to create and update checks by sending HTTP POST or GET requests to endpoint. | ||
|
||
```yaml title="webhook.yaml" | ||
apiVersion: canaries.flanksource.com/v1 | ||
kind: Canary | ||
metadata: | ||
name: webhook | ||
spec: | ||
webhook: | ||
# webhook names must be unique, | ||
name: webhook-endpoint-1 | ||
transform: | ||
expr: | | ||
[{ | ||
'name': 'Webhook/' + results.json.name, | ||
'pass': results.json.status == "healthy", | ||
}].toJSON() | ||
``` | ||
This example: | ||
1. Defines a webhook named `webhook-endpoint-1` accessible via `http://<host>/webhooks/webhook-endpoint-1` | ||
2. Transforms the incoming JSON into [check](#output) | ||
|
||
This webhook can be called with: | ||
|
||
```bash | ||
curl --header "Content-Type: application/json" \ | ||
--request POST \ | ||
--data '{"name":"sample-webhook","status":"healthy"}' \ | ||
http://localhost/webhooks/webhook-endpoint-1 | ||
``` | ||
|
||
|
||
## Input | ||
|
||
The request is available to the transformation function with these fields: | ||
|
||
<Fields rows={[ | ||
{ | ||
field: 'results.json', | ||
description: 'If `Content-Type: application/json` unmarshalls the request body to a JSON ', | ||
scheme: '`JSON Object|Array`' | ||
}, | ||
{ | ||
field: 'results.headers', | ||
|
||
scheme: "`map[string]string`" | ||
}, { | ||
field: 'results.content', | ||
description: 'Request body text, See [YAML](/reference/scripting/cel#yaml), [CSV](/reference/scripting/cel#csv)', | ||
scheme: 'string' | ||
} | ||
]}/> | ||
|
||
## Output | ||
|
||
The return value is a list of checks | ||
|
||
<TransformFields/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.