Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification events #240

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mission-control/docs/notifications/events/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Component status updates emit the following events
- `component.healthy`
- `component.unhealthy`
- `component.warning`
- `component.error`
- `component.info`
- `component.unknown`

## Variables

Expand Down
91 changes: 54 additions & 37 deletions mission-control/docs/notifications/events/configs.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
---
title: Components
title: Configs
---

Component status updates emit the following events
Configs emit events when their health changes or when they are created, modified, or removed.

**Health events**

- `config.healthy`
- `config.unhealthy`
- `config.warning`
- `config.unknown`

**State events**

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

## Variables

| Field | Description | Schema | Optional |
| ----------- | ----------------------------- | ------------------------- | -------- |
| `config` | The component object | [`Component`](#component) | |
| `agent` | Agent details (if applicable) | [`Agent`](#agent) | `true` |
| `permalink` | A link to the health check | `string` | |

### Component

| Field | Description | Schema | Optional |
| ----------------- | -------------------------------------------- | ------------------- | -------- |
| `id` | The id of the component | `uuid` | |
| `description` | The description of the component | `string` | |
| `external_id` | The external id of the component | `string` | |
| `hidden` | Whether the component is hidden | `bool` | |
| `labels` | The labels of the component | `map[string]string` | `true` |
| `name` | The name of the component | `string` | |
| `namespace` | The namespace of the component | `string` | |
| `parent_id` | The id of the parent component | `uuid` | `true` |
| `properties` | The properties of the component | `map[string]string` | `true` |
| `silenced` | Whether the component is silenced | `bool` | |
| `status_reason` | The status reason of the component | `string` | |
| `status` | The status of the component | `string` | |
| `summary` | The summary of the component | `map[string]string` | `true` |
| `text` | The text of the component | `string` | |
| `topology_type` | The type of the topology | `string` | |
| `type` | The type of the component | `string` | |
| `cost_per_minute` | The cost per minute of the component | `float64` | |
| `cost_total_1d` | The cost total 1d of the component | `float64` | |
| `cost_total_7d` | The cost total 7d of the component | `float64` | |
| `cost_total_30d` | The cost total 30d of the component | `float64` | |
| `created_by` | Id of the person that created this component | `uuid` | |
| `created_at` | Created timestamp | `time.Time` | |
| `updated_at` | Updated timestamp | `time.Time` | |
| `deleted_at` | Deleted timestamp | `time.Time` | `true` |
| Field | Description | Schema | nullable |
| ----------- | ----------------------------- | ------------------- | -------- |
| `config` | The config object | [`Config`](#config) | |
| `agent` | Agent details (if applicable) | [`Agent`](#agent) | `true` |
| `permalink` | A link to the config item | `string` | |

### Config

| Field | Description | Schema | nullable |
| --------------- | -------------------------------- | --------------- | -------- |
| `id` | ID of the config item | `uuid` | |
| `agent_id` | ID of the agent | `uuid` | `true` |
| `config_class` | Class of the config item | `string` | |
| `config` | Configuration | `string` | `true` |
| `created_at` | Creation timestamp | `time.Time` | |
| `delete_reason` | Reason for deletion | `string` | `true` |
| `deleted_at` | Deletion timestamp | `time.Time` | `true` |
| `description` | Description | `string` | `true` |
| `external_id` | External IDs | `[]string` | `true` |
| `health` | Health | `Health` | `true` |
| `labels` | Labels | `JSONStringMap` | `true` |
| `name` | Name | `string` | `true` |
| `properties` | Properties | `Properties` | `true` |
| `ready` | Whether the config item is ready | `bool` | |
| `scraper_id` | ID of the scraper | `string` | `true` |
| `source` | Source | `string` | `true` |
| `status` | Status | `string` | `true` |
| `tags` | Tags | `JSONStringMap` | |
| `type` | Type | `string` | |
| `updated_at` | Update timestamp | `time.Time` | `true` |

### Agent

Expand All @@ -55,9 +60,21 @@ Component status updates emit the following events

## Notification Defaults

**Health events**

```
# Title
Config {{.config.name}} health updated to {{.config.health}}

# Body
[Reference]({{.permalink}})
```

**State events**

```
# Title
Config {{.config.name}} status updated to {{.config.status}}
Config {{.config.name}} was <new-state>

# Body
[Reference]({{.permalink}})
Expand Down
4 changes: 2 additions & 2 deletions mission-control/docs/notifications/events/health-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Health checks emit 2 events

1. `check.passed`
2. `check.failed`
- `check.passed`
- `check.failed`

## Variables

Expand Down
18 changes: 18 additions & 0 deletions mission-control/docs/notifications/examples/kube-job-failing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Kubernetes Job Failing
---

```yaml title="cronjob-alerts.yaml"
---
apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: cronjob-alerts
namespace: default
spec:
events:
- config.unhealthy
to:
connection: connection://flanksource-slack
filter: config.type == 'Kubernetes::CronJob'
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: PodCrashLooping notification
---

```yaml title="podcrashlooping-alerts.yaml"
---
apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: podcrashlooping-alerts
namespace: default
spec:
events:
- config.unhealthy
filter: config.type == 'Kubernetes::Pod' && config.status == 'CrashLoopBackOff'
to:
# use the slack connection as the recipient for this notification
connection: connection://flanksource-slack
```
32 changes: 15 additions & 17 deletions mission-control/docs/reference/notifications/_notification.mdx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@

| Field | Description | Scheme | Required | Templatable |
| ---------- | ------------------------------------------------------------------ | ------------------------- | -------- | ----------- |
| `events` | | [][Event](./events) | `true` ||
| `to` | Notification recipient | [`Recipient`](#recipient) | `true` ||
| `title` | Channel dependant e.g. subject for email | <CommonLink to="gotemplate">Go Template </CommonLink> | | `true` |
| `template` |Channel dependant e.g. email body for email | <CommonLink to="gotemplate">Go Template </CommonLink> | | `true` |
| `filter` | Filter out unwanted notifications | <CommonLink to="cel">CEL</CommonLink> | | |

| Field | Description | Scheme | Required | Templatable |
| ---------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | -------- | ----------- |
| `events` | | [[]Event](./events) | `true` | |
| `to` | Notification recipient | [`Recipient`](#recipient) | `true` | |
| `title` | Channel dependant e.g. subject for email | <CommonLink to="gotemplate">Go Template </CommonLink> | | `true` |
| `template` | Channel dependant e.g. email body for email | <CommonLink to="gotemplate">Go Template </CommonLink> | | `true` |
| `filter` | Filter out events. If the filter evaluates to true, the notification is processed - else discarded. | <CommonLink to="cel">CEL</CommonLink> | | |

### Recipient

| Field | Description | Schema |
| ------------ | ---------------------------------------------------------------- | ------------------- |
| `person` | | `UUID` or `email` of a person |
| `team` | Every member of the team with an email will receive a notification | `UUID` or `name` of team |
| `email` | Send an email to an external user | `email` |
| `connection` | Connection to external service | `connection` |
| `url` | Custom notification URL | [Channel](./channels) |
| `properties` | *Only applicable if `url` is specified* | `map[string]string` |
| Field | Description | Schema |
| ------------ | ------------------------------------------------------------------ | ----------------------------- |
| `person` | | `UUID` or `email` of a person |
| `team` | Every member of the team with an email will receive a notification | `UUID` or `name` of team |
| `email` | Send an email to an external user | `email` |
| `connection` | Connection to external service | `connection` |
| `url` | Custom notification URL | [Channel](./channels) |
| `properties` | _Only applicable if `url` is specified_ | `map[string]string` |

> Only one recipient can be specified
26 changes: 21 additions & 5 deletions mission-control/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ const sidebars = {
slug: '/notifications/events'
},
items: [
{
type: 'doc',
id: 'notifications/events/configs',
label: 'Configs'
},
{
type: 'doc',
id: 'notifications/events/components',
Expand All @@ -123,11 +128,6 @@ const sidebars = {
id: 'notifications/events/health-checks',
label: 'Health Checks'
},
// {
// type: 'doc',
// id: 'notifications/events/incidents',
// label: 'Incidents'
// }
]
},
{
Expand All @@ -138,6 +138,22 @@ const sidebars = {
{
type: 'category',
label: 'Examples',
items: [
{
type: 'doc',
id: 'notifications/examples/kube-podcrashlooping',
label: 'PodCrashLooping'
},
{
type: 'doc',
id: 'notifications/examples/kube-job-failing',
label: 'Kubernetes Job Failing'
},
]
},
{
type: 'category',
label: 'Tutorials',
items: [
{
type: 'doc',
Expand Down
Loading