Skip to content

Commit

Permalink
docs: slack template for components, config & check events
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Aug 30, 2024
1 parent 02c8984 commit 0529fff
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 82 deletions.
35 changes: 19 additions & 16 deletions mission-control/docs/notifications/events/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@ Component status updates emit the following events
- `component.warning`
- `component.unknown`

The default notification template used is:
_ **Title:** `Component {{.component.name}} is {{.component.health}}`
_ **Body:**

```
### Labels:
{{range $k, $v := .component.labels}}**{{$k}}**: {{$v}}
{{end}}
[Reference]({{.permalink}})
```

Sample notification:

```yaml title="notification.yaml"
```yaml title="unhelthy-component-notification.yaml"
apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
Expand All @@ -42,9 +29,25 @@ spec:
email: [email protected]
```
The notification title and body can be changed using the variables below:
## Default Templates
The default notification template used is:
### Title
## Variables
```
{{ if ne channel "slack"}}Component {{.component.name}} is {{.component.health}}{{end}}
```

### Template

```txt file=../../../modules/mission-control/notification/templates/component.health
```

## Template Variables

The notification title and body can be changed using the variables below:

| Field | Description | Schema | Optional |
| ----------- | ----------------------------- | ------------------------- | -------- |
Expand Down
90 changes: 53 additions & 37 deletions mission-control/docs/notifications/events/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,76 @@ Configs emit events when their health changes or when they are created, modified
- `config.warning`
- `config.unknown`

The default notification template for health events is:

- **Title:** `{{.config.type}} {{.config.name}} is {{.config.health}}`
- **Body:**

```
### Labels:
{{range $k, $v := .config.labels}}**{{$k}}**: {{$v}}
{{end}}
[Reference]({{.permalink}})
```

**State events**

- `config.created`
- `config.updated`
- `config.deleted`

The default notification template for state events is:

- **Title:** `{{.config.type}} {{.config.name}} was [created/updated/deleted]`
- **Body:**
- `config.deleted` _(Soft Delete)_

```
### Labels:
{{range $k, $v := .config.labels}}**{{$k}}**: {{$v}}
{{end}}
[Reference]({{.permalink}})
```

Sample notification:

```yaml title="notification.yaml"
```yaml title="ec2-instance-updates.yaml"
apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: ec2-instance-create-alert
name: ec2-instance-changes
namespace: default
spec:
events:
- config.created
- config.updated
- config.deleted
filter: config.type == 'AWS::EC2::Instance'
title: New EC2 instance {{.config.name}} created
body: |
Region: {{.config.tags['region']}}
Zone: {{.config.tags['zone']}}
Account: {{.config.tags['account']}}
to:
email: [email protected]
```
## Variables
```yaml title="ec2-health-notification.yaml"
apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: ec2-instance-health-alerts
namespace: default
spec:
events:
- config.unhealthy
- config.warning
filter: config.type == 'AWS::EC2::Instance'
to:
email: [email protected]
```
## Default Templates
The default notification template for health events is:
### Health notifications
#### Title
```
{{ if ne channel "slack"}}{{.config.type}} {{.config.name}} is {{.config.health}}{{end}}
```

#### Template

```txt file=../../../modules/mission-control/notification/templates/config.health
```

### State change notifications

#### Title

```
{{ if ne channel "slack"}}{{.config.type}} {{.config.name}} was {{.new_state}}{{end}}
```

#### Template

```txt file=../../../modules/mission-control/notification/templates/config.db.update
```

## Template Variables

| Field | Description | Schema | nullable |
| ----------- | ----------------------------- | ------------------- | -------- |
Expand Down Expand Up @@ -103,5 +121,3 @@ spec:
| `id` | The id of the agent | `uuid` | |
| `name` | The name of the agent | `string` | |
| `description` | Short description of the agent | `string` | |

## Notification Defaults
62 changes: 33 additions & 29 deletions mission-control/docs/notifications/events/health-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,8 @@ title: Health Checks

Health checks emit 2 events

- **`check.passed`**:

- **Title:** `Check {{.check.name}} has passed`
- **Body:**
```
Canary: {{.canary.name}}
{{if .agent}}Agent: {{.agent.name}}{{end}}
{{if .status.message}}Message: {{.status.message}} {{end}}
### Labels:
{{range $k, $v := .check.labels}}**{{$k}}**: {{$v}}
{{end}}
[Reference]({{.permalink}})
```

- **`check.failed`**:
- **Title:** `Check {{.check.name}} has failed`
- **Body:**
```
Canary: {{.canary.name}}
{{if .agent}}Agent: {{.agent.name}}{{end}}
Error: {{.status.error}}
### Labels:
{{range $k, $v := .check.labels}}**{{$k}}**: {{$v}}
{{end}}
[Reference]({{.permalink}})
```

Sample notification:
- `check.passed`
- `check.failed`

```yaml title="notification.yaml"
apiVersion: mission-control.flanksource.com/v1
Expand All @@ -53,7 +27,37 @@ spec:
email: [email protected]
```
## Variables
## Default Templates
### check.passed
#### Title
```
{{ if ne channel "slack"}}Check {{.check.name}} has passed{{end}}
```

#### Template

```txt file=../../../modules/mission-control/notification/templates/check.passed
```

### check.failed

#### Title

```
{{ if ne channel "slack"}}Check {{.check.name}} has failed{{end}}
```

#### Template

```txt file=../../../modules/mission-control/notification/templates/check.failed
```

## Template Variables

| Field | Description | Schema | Optional |
| ----------- | ----------------------------- | ------------------------------ | -------- |
Expand Down

0 comments on commit 0529fff

Please sign in to comment.