Skip to content

Commit

Permalink
chore: canary fixture updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 1, 2024
1 parent 9cd8f93 commit db554c9
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 236 deletions.
22 changes: 6 additions & 16 deletions canary-checker/docs/concepts/expressions/health-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
title: Health Evaluation
---

All checks expose a health stats of passing (Green) or failing (Red), for example the HTTP check fails if the status is `200 >= code < 299`
All checks expose a health stats of passing (Green) or failing (Red).
For example the HTTP check fails if the status is `200 >= code < 299`
these default behaviors can be changed using the `test` field:

In the example below the http check fails if the SSL certificate expiry age is below 7 days

```yaml title=http-check-expr.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-check-expr
spec:
interval: 30
http:
- name: http pass response 200 status code
endpoint: https://httpbin.demo.aws.flanksource.com/status/200
test:
expr: "code in [200,201,301] && sslAge < Duration('7d')"
In the example below the http check fails if the HTTP response header contains an 'Authorization' field.

```yaml title=http-check-expr.yaml file=../../../../modules/canary-checker/fixtures/minimal/http_no_auth_pass.yaml
```

:::info Boolean
Expand All @@ -28,7 +18,7 @@ spec:
See <CommonLink to="cel">Cel Expressions</CommonLink> for a function reference

:::note Javascript and Go Templating
While `test` fields do support Javascript and Go Text Templates, they are not recommended for health evaluations due to their verbosity and performance.
While `test` fields do support Javascript and Go Templates, they are not recommended for health evaluations due to their verbosity and performance.
:::

## Variables
Expand Down
41 changes: 1 addition & 40 deletions canary-checker/docs/concepts/metrics/custom-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,7 @@ Canary checker can export custom metrics from any check type, replacing and/or c

In the example below, exchange rates against the USD are exported by first calling an HTTP api and then using the values from the JSON response to create the metrics:

```yaml title="exchange-rates-exporter.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: exchange-rates
spec:
schedule: 'every 1 @hour'
http:
- name: exchange-rates
url: https://api.frankfurter.app/latest?from=USD&to=GBP,EUR,ILS
metrics:
- name: exchange_rate
type: gauge
value: result.json.rates.GBP
labels:
- name: 'from'
value: 'USD'
- name: to
value: GBP

- name: exchange_rate
type: gauge
value: result.json.rates.EUR
labels:
- name: 'from'
value: 'USD'
- name: to
value: EUR

- name: exchange_rate
type: gauge
value: result.json.rates.ILS
labels:
- name: 'from'
value: 'USD'
- name: to
value: ILS
- name: exchange_rate_api
type: histogram
value: result.elapsed.getMilliseconds()
```yaml title="exchange-rates-exporter.yaml" file=../../../../modules/canary-checker/fixtures/minimal/metrics-multiple.yaml
```

Which would output:
Expand Down
15 changes: 1 addition & 14 deletions canary-checker/docs/concepts/secret-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,7 @@ Avoid inlining secrets, use `valueFrom` and <CommonLink to="authentication">EnvV

Using a HTTP health check as an example for static values:

```yaml title="http-basic-auth-static.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-basic-auth
spec:
http:
- url: https://httpbin.org/basic-auth/hello/world
responseCodes: [200]
authentication:
username:
value: hello
password:
value: world
```yaml title="http-basic-auth-static.yaml" file=../../../modules/canary-checker/fixtures/minimal/http_auth.yaml
```

## Configmaps
Expand Down
18 changes: 4 additions & 14 deletions canary-checker/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,14 @@ import { HiOutlineExternalLink } from "react-icons/hi";
-n "canary-checker" \
--create-namespace
```
<p/>
<p/>

2. Create a new check

```yaml title="canary.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-check
spec:
interval: 30
http:
- name: basic-check
url: https://httpbin.demo.aws.flanksource.com/status/200
- name: failing-check
url: https://httpbin.demo.aws.flanksource.com/status/500
```yaml title="canary.yaml" file=../../modules/canary-checker/fixtures/minimal/http_auth.yaml
```
<p/>
<p/>

3. And then apply it to the cluster:

```shell
Expand Down
53 changes: 3 additions & 50 deletions canary-checker/docs/reference/1-alert-manager.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@ Checks [Prometheus AlertManager](https://prometheus.io/docs/alerting/latest/aler
The following example [transforms](../concepts/expressions/transforms) the list of alerts so that each alert becomes a single check result. Without the transform the health check fails if any alerts are firing.

```yaml title="alert-manager-check.yaml" file=../../../modules/canary-checker/fixtures/datasources/alertmanager_mix.yaml
apiVersion: canaries.flanksource.com/v12
kind: Canary
metadata:
name: alertmanager-check
spec:
schedule: "*/5 * * * *"
alertmanager:
- url: alertmanager.monitoring.svc
alerts:
- .*
ignore:
- KubeScheduler.*
- Watchdog
transform:
expr: |
results.alerts.map(r, {
'name': r.name + r.fingerprint,
'namespace': 'namespace' in r.labels ? r.labels.namespace : '',
'labels': r.labels,
'icon': 'alert',
'message': r.message,
'description': r.message,
}).toJSON()
```

<HealthCheck name="alertmanager" rows={[
Expand Down Expand Up @@ -125,38 +102,14 @@ Lookup specifies the type of lookup to perform.
/>

</SkipOSS>

## Inserting checks into different namespaces

You can specify different namespaces for checks using the `namespace` field. This is helpful when checks are dynamically generated via transformation
and need to be assigned their respective namespace.

```yaml title="alertmanager.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: alertmanager
spec:
interval: 30
alertmanager:
- url: https://alertmanager.demo.aws.flanksource.com
name: alertmanager-check
alerts:
- .*
ignore:
- KubeScheduler.*
exclude_filters:
namespace: elastic-system
transform:
expr: |
results.alerts.map(r, {
'name': r.name + r.fingerprint,
// highlight-next-line
'namespace': 'namespace' in r.labels ? r.labels.namespace : '',
'labels': r.labels,
'icon': 'alert',
'message': r.message,
'description': r.message,
}).toJSON()

```yaml title="alert-manager-check.yaml" file=../../../modules/canary-checker/fixtures/datasources/alertmanager_mix.yaml {20}
```

The above alertmanager canary can reside on any namespace and the check it generates are assigned the correct namespace derived from the alerts.
Expand Down
4 changes: 2 additions & 2 deletions canary-checker/docs/reference/1-aws-config-rule.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ There are 3 options when connecting to AWS:

2. `connection`, this is the recommended method, connections are reusable and secure

```yaml title="aws-connection.yaml"
```yaml title="aws-connection.yaml" {9}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
Expand All @@ -53,7 +53,7 @@ There are 3 options when connecting to AWS:
3. `accessKey` and `secretKey` <CommonLink to="authentication">_EnvVar_</CommonLink> with the credentials stored in a secret.

```yaml title="aws.yaml"
```yaml title="aws.yaml" {9-19}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
Expand Down
37 changes: 0 additions & 37 deletions canary-checker/docs/reference/1-folder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,80 +110,43 @@ The following fields are available in `test`, `display` and `transform` [express
<div>
```yaml title="exec_artifact.yaml" file=../../../modules/canary-checker/fixtures/datasources/SFTP/sftp_pass.yaml
```

</div>
</details>

### S3

<Fields connection="aws" />

```yaml title="s3-check.yaml"
# ...
kind: Canary
spec:
folder:
//highlight-next-line
- path: s3://bucket/folder
awsConnection:
# ...
```

<div className="mt-5"/>
<details summary="S3 Bucket" >
<div>
```yaml title="exec_artifact.yaml" file=../../../modules/canary-checker/fixtures/datasources/s3_bucket_pass.yaml
```

</div>
</details>

### SMB

<Fields connection="smb" />

```yaml title="smb-check.yaml"
# ...
kind: Canary
spec:
folder:
//highlight-next-line
- path: smb:\\192.168.1.9\Some Public Folder\somedir
smbConnection:
#...
```

<Fields connection="smb" />

<div className="mt-5"/>
<details summary="SMB / CIFS" >
<div>
```yaml title="smb.yaml" file=../../../modules/canary-checker/fixtures/quarantine/smb_pass.yaml
```

</div>
</details>

### GCS

<Fields connection="gcp" />

```yaml title="gcs-check.yaml"
# ...
kind: Canary
spec:
folder:
//highlight-next-line
- path: gcs://bucket/folder
gcpConnection:
# ...
```

<div className="mt-5"/>
<details summary="GCS Check" >
<div>
```yaml title="gcs.yaml" file=../../../modules/canary-checker/fixtures/datasources/GCP/folder_pass.yaml
```

</div>
</details>
15 changes: 3 additions & 12 deletions canary-checker/docs/reference/1-git.mdx
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
---
title: Git
---

# <Icon name="git" /> Git

<Standard />
<Standard />

Execute as SQL style query against a github repo using [mergestat-lite](https://github.com/mergestat/mergestat-lite).

```yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: github-check
spec:
schedule: "@every 1m"
github:
- githubToken: <token>
query: SELECT count(*) FROM commits WHERE author_email = '[email protected]'
```yaml file=../../../modules/canary-checker/fixtures/git/git_check_pass.yaml title='github-check.yaml'
```

<HealthCheck name="github" rows={[
{field: "githubToken", description: "Github Personal Access Token", scheme: 'EnvVar', required: true},
{field: "query", description: "Query to be executed. See [mergestat-lite](https://github.com/mergestat/mergestat-lite) for syntax", scheme: 'string', required: true},
]}/>
2 changes: 1 addition & 1 deletion canary-checker/docs/reference/1-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_class_name: popular
The Kubernetes check performs requests on Kubernetes resources such as Pods to get the desired information.


```yaml title="junit.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-minimal_pass.yaml
```yaml title="kubernetes.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-minimal_pass.yaml
```

<HealthCheck name="kubernetes" edition="standard" connection="kubeconfig" rows={[
Expand Down
13 changes: 1 addition & 12 deletions canary-checker/docs/reference/3-gcs-database-backup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@ sidebar_class_name: beta

Checks if a Google Cloud SQL instance has been successfully backed up recently.

```yaml title="gcp-database.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: database-backup-check
spec:
interval: 60
databaseBackup:
- maxAge: 6h
gcp:
project: google-project-name
instance: cloudsql-instance-name
```yaml title="gcs-database.yaml" file=../../../modules/canary-checker/fixtures/datasources/GCP/database_backup.yaml
```

| Field | Description | Scheme | Required |
Expand Down
Loading

0 comments on commit db554c9

Please sign in to comment.