diff --git a/mission-control/docs/notifications/events/components.md b/mission-control/docs/notifications/events/components.md deleted file mode 100644 index afb3608..0000000 --- a/mission-control/docs/notifications/events/components.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Components -description: Events that fire on topology/component changes ---- - -Components updates emit the following events when its health changes - -- `component.healthy` -- `component.unhealthy` -- `component.warning` -- `component.unknown` - -```yaml title="unhelthy-component-notification.yaml" -apiVersion: mission-control.flanksource.com/v1 -kind: Notification -metadata: - name: web-api-component-alert - namespace: default -spec: - events: - - component.unhealthy - filter: component.type == 'WebAPI' - title: WebAPI {{.component.name}} failing - body: | - ## Component Failed - Status: {{.component.status}} | {{.component.status_reason}} - Last updated: {{.component.updated_at}} - to: - email: alerts@acme.com -``` - -## Default Templates - -The default notification template used is: - -### Title - -``` -{{ 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 | -| ----------- | ----------------------------- | ------------------------- | -------- | -| `component` | 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` | - -### Agent - -| Field | Description | Schema | Optional | -| ------------- | ------------------------------ | -------- | -------- | -| `id` | The id of the agent | `uuid` | | -| `name` | The name of the agent | `string` | | -| `description` | Short description of the agent | `string` | | diff --git a/mission-control/docs/notifications/events/components.mdx b/mission-control/docs/notifications/events/components.mdx new file mode 100644 index 0000000..add9076 --- /dev/null +++ b/mission-control/docs/notifications/events/components.mdx @@ -0,0 +1,60 @@ +--- +title: Components +description: Events that fire on topology/component changes +--- + +import { ComponentHealthEnv, AgentEnv, ComponentEnv } from "../../reference/notifications/_env_vars.mdx" + +Components updates emit the following events when its health changes + +- `component.healthy` +- `component.unhealthy` +- `component.warning` +- `component.unknown` + +```yaml title="unhelthy-component-notification.yaml" +apiVersion: mission-control.flanksource.com/v1 +kind: Notification +metadata: + name: web-api-component-alert + namespace: default +spec: + events: + - component.unhealthy + filter: component.type == 'WebAPI' + title: WebAPI {{.component.name}} failing + body: | + ## Component Failed + Status: {{.component.status}} | {{.component.status_reason}} + Last updated: {{.component.updated_at}} + to: + email: alerts@acme.com +``` + +## Default Templates + +The default notification template used is: + +### Title + +``` +{{ 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: + + +### Component + + + +### Agent + \ No newline at end of file diff --git a/mission-control/docs/notifications/events/configs.md b/mission-control/docs/notifications/events/configs.md deleted file mode 100644 index 9e50db8..0000000 --- a/mission-control/docs/notifications/events/configs.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: Configs -description: Events that fire on config changes and health ---- - -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` _(Soft Delete)_ - -```yaml title="ec2-instance-updates.yaml" -apiVersion: mission-control.flanksource.com/v1 -kind: Notification -metadata: - name: ec2-instance-changes - namespace: default -spec: - events: - - config.created - - config.updated - - config.deleted - filter: config.type == 'AWS::EC2::Instance' - to: - email: alerts@acme.com -``` - -```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: alerts@acme.com -``` - -## 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 | -| ----------- | ----------------------------- | ------------------- | -------- | -| `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 - -| Field | Description | Schema | Optional | -| ------------- | ------------------------------ | -------- | -------- | -| `id` | The id of the agent | `uuid` | | -| `name` | The name of the agent | `string` | | -| `description` | Short description of the agent | `string` | | diff --git a/mission-control/docs/notifications/events/configs.mdx b/mission-control/docs/notifications/events/configs.mdx new file mode 100644 index 0000000..6997fb3 --- /dev/null +++ b/mission-control/docs/notifications/events/configs.mdx @@ -0,0 +1,102 @@ +--- +title: Configs +description: Events that fire on config changes and health +--- + +import { + ConfigDBStateEnv, CheckHealthEnv, ConfigHealthEnv, ComponentHealthEnv, + AgentEnv, ConfigItemEnv, ComponentEnv, CanaryEnv, CheckEnv, CheckStatus, + Uptime, Latency +} from "../../reference/notifications/_env_vars.mdx" + +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` _(Soft Delete)_ + +```yaml title="ec2-instance-updates.yaml" +apiVersion: mission-control.flanksource.com/v1 +kind: Notification +metadata: + name: ec2-instance-changes + namespace: default +spec: + events: + - config.created + - config.updated + - config.deleted + filter: config.type == 'AWS::EC2::Instance' + to: + email: alerts@acme.com +``` + +```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: alerts@acme.com +``` + +## 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 + +### Config State Env + + +### Config Health Env + + +### Config Item + + +### Agent + diff --git a/mission-control/docs/notifications/events/health-checks.md b/mission-control/docs/notifications/events/health-checks.md deleted file mode 100644 index 521f542..0000000 --- a/mission-control/docs/notifications/events/health-checks.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -description: Events that fire when health checks pass or fail -title: Health Checks ---- - -Health checks emit 2 events - -- `check.passed` -- `check.failed` - -```yaml title="notification.yaml" -apiVersion: mission-control.flanksource.com/v1 -kind: Notification -metadata: - name: api-http-fail-alert - namespace: default -spec: - events: - - check.failed - filter: check.type == 'http' - title: API HTTP Check {{.check.name}} failing - body: | - ## Check Failed - Error: {{.status.error}} - Failed at {{.status.created_at}} - to: - email: alerts@acme.com -``` - -## 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 | -| ----------- | ----------------------------- | ------------------------------ | -------- | -| `canary` | The parent canary object | [`Canary`](#canary) | | -| `check` | The check | [`Check`](#check) | | -| `agent` | Agent details (if applicable) | [`Agent`](#check) | `true` | -| `status` | Check status details | [`CheckStatus`](#check-status) | | -| `permalink` | A link to the health check | `string` | | - -### Canary - -| Field | Description | Schema | Optional | -| ------------ | ---------------------------- | ------------------- | -------- | -| `id` | The id of the canary | `uuid` | | -| `name` | The name of the canary | `string` | | -| `namespace` | The namespace of the canary | `string` | | -| `agent_id` | The agent id of the canary | `string` | | -| `labels` | The labels of the canary | `map[string]string` | `true` | -| `source` | The source of the canary | `string` | | -| `created_at` | The created at of the canary | `string` | | -| `updated_at` | The updated at of the canary | `string` | | -| `deleted_at` | The deleted at of the canary | `string` | `true` | - -### Check - -| Field | Description | Schema | Optional | -| ---------------------- | -------------------------------------- | --------------------- | -------- | -| `id` | The id of the check | `uuid` | | -| `type` | The type of the check | `string` | | -| `name` | The name of the check | `string` | | -| `labels` | The labels of the check | `map[string]string` | `true` | -| `description` | The description of the check | `string` | | -| `status` | Check status details | `string` | | -| `severity` | The severity of the check | `string` | `true` | -| `uptime` | The past 1 hour uptime summary | [`Uptime`](#uptime) | `true` | -| `latency` | The past 1 hour latency summary | [`Latency`](#latency) | `true` | -| `transformed` | Whether the check has been transformed | `bool` | | -| `last_runtime` | The last runtime of the check | `time.Time` | `true` | -| `next_runtime` | The next runtime of the check | `time.Time` | `true` | -| `last_transition_time` | The last transition time of the check | `time.Time` | `true` | -| `created_at` | The created at of the check | `time.Time` | | -| `updated_at` | The updated at of the check | `time.Time` | | -| `deleted_at` | The deleted at of the check | `time.Time` | `true` | - -#### Uptime - -| Field | Description | Schema | Optional | -| ----------- | ------------------------------------ | ----------- | -------- | -| `passed` | The number of checks that passed | `int` | | -| `failed` | The number of checks that failed | `int` | | -| `p100` | The percentage of checks that passed | `float64` | | -| `last_pass` | The last time a check passed | `time.Time` | `true` | -| `last_fail` | The last time a check failed | `time.Time` | `true` | - -#### Latency - -| Field | Description | Schema | Optional | -| ----------- | ------------------------ | --------- | -------- | -| `p99` | The latency of the check | `float64` | `true` | -| `p97` | The latency of the check | `float64` | `true` | -| `p95` | The latency of the check | `float64` | `true` | -| `rolling1h` | The latency of the check | `float64` | | - -### Agent - -| Field | Description | Schema | Optional | -| ------------- | ------------------------------ | -------- | -------- | -| `id` | The id of the agent | `uuid` | | -| `name` | The name of the agent | `string` | | -| `description` | Short description of the agent | `string` | | - -### Check Status - -| Field | Description | Schema | Optional | -| ------------ | ----------------------------------------------- | ----------- | -------- | -| `check_id` | The id of the check associated with this status | `uuid` | | -| `status` | The status of the check | `bool` | | -| `invalid` | Whether the check errored out | `bool` | | -| `time` | The time of the check | `string` | | -| `duration` | The duration of the check | `int` | | -| `message` | The success message of the check | `string` | | -| `error` | The error of the check in case of failure | `string` | | -| `created_at` | The created at of the check | `time.Time` | | - -## Notification Template Defaults diff --git a/mission-control/docs/notifications/events/health-checks.mdx b/mission-control/docs/notifications/events/health-checks.mdx new file mode 100644 index 0000000..a4b1585 --- /dev/null +++ b/mission-control/docs/notifications/events/health-checks.mdx @@ -0,0 +1,90 @@ +--- +description: Events that fire when health checks pass or fail +title: Health Checks +--- + +import { + ConfigDBStateEnv, CheckHealthEnv, ConfigHealthEnv, ComponentHealthEnv, + AgentEnv, ConfigItemEnv, ComponentEnv, CanaryEnv, CheckEnv, CheckStatus, + Uptime, Latency +} from "../../reference/notifications/_env_vars.mdx" + +Health checks emit 2 events + +- `check.passed` +- `check.failed` + +```yaml title="notification.yaml" +apiVersion: mission-control.flanksource.com/v1 +kind: Notification +metadata: + name: api-http-fail-alert + namespace: default +spec: + events: + - check.failed + filter: check.type == 'http' + title: API HTTP Check {{.check.name}} failing + body: | + ## Check Failed + Error: {{.status.error}} + Failed at {{.status.created_at}} + to: + email: alerts@acme.com +``` + +## 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 + +### Config Health Env + + +### Check Health Env + + +### Agent + + +### Canary + + +### Check + + +### CheckStatus + + +### Uptime + + +### Latency + \ No newline at end of file diff --git a/mission-control/docs/reference/notifications/_env_vars.mdx b/mission-control/docs/reference/notifications/_env_vars.mdx index 8f7ff9d..0d2d338 100644 --- a/mission-control/docs/reference/notifications/_env_vars.mdx +++ b/mission-control/docs/reference/notifications/_env_vars.mdx @@ -3,17 +3,17 @@ export function CheckHealthEnv() { rows={[ { "field": "check", - "scheme": "TODO", + "scheme": "[`check`](#check)", "description": "Check" }, { "field": "canary", - "scheme": "TODO", + "scheme": "[`canary`](#canary)", "description": "canary" }, { "field": "status", - "scheme": "TODO", + "scheme": "[`checkstatus`](#check-status)", "description": "check status" }, { @@ -106,7 +106,7 @@ export function AgentEnv() { rows={[ { "field": "id", - "scheme": "uuid", + "scheme": "`uuid`", "description": "The id of the agent" }, { @@ -129,12 +129,12 @@ export function ConfigItemEnv() { rows={[ { "field": "id", - "scheme": "uuid", + "scheme": "`uuid`", "description": "ID of the config item" }, { "field": "agent_id", - "scheme": "uuid", + "scheme": "`uuid`", "description": "ID of the agent" }, { @@ -149,7 +149,7 @@ export function ConfigItemEnv() { }, { "field": "created_at", - "scheme": "time.Time", + "scheme": "`time.Time`", "description": "Creation timestamp" }, { @@ -159,7 +159,7 @@ export function ConfigItemEnv() { }, { "field": "deleted_at", - "scheme": "time.Time", + "scheme": "`time.Time`", "description": "Deletion timestamp" }, { @@ -169,17 +169,17 @@ export function ConfigItemEnv() { }, { "field": "external_id", - "scheme": "[]string", + "scheme": "`[]string`", "description": "External IDs" }, { "field": "health", - "scheme": "Health", - "description": "Health" + "scheme": "`Health`", + "description": "`Health`" }, { "field": "labels", - "scheme": "JSONStringMap", + "scheme": "`JSONStringMap`", "description": "Labels" }, { @@ -189,8 +189,8 @@ export function ConfigItemEnv() { }, { "field": "properties", - "scheme": "Properties", - "description": "Properties" + "scheme": "`Properties`", + "description": "`Properties`" }, { "field": "ready", @@ -214,7 +214,7 @@ export function ConfigItemEnv() { }, { "field": "tags", - "scheme": "JSONStringMap", + "scheme": "`JSONStringMap`", "description": "Tags" }, { @@ -224,36 +224,60 @@ export function ConfigItemEnv() { }, { "field": "updated_at", - "scheme": "time.Time", + "scheme": "`time.Time`", "description": "Update timestamp" } ]} /> } - export function CanaryEnv() { return @@ -264,7 +288,7 @@ export function ComponentEnv() { rows={[ { "field": "id", - "scheme": "uuid", + "scheme": "`uuid`", "description": "The id of the component" }, { @@ -284,7 +308,7 @@ export function ComponentEnv() { }, { "field": "labels", - "scheme": "map[string]string", + "scheme": "`map[string]string`", "description": "The labels of the component", }, { @@ -299,12 +323,12 @@ export function ComponentEnv() { }, { "field": "parent_id", - "scheme": "uuid", + "scheme": "`uuid`", "description": "The id of the parent component", }, { "field": "properties", - "scheme": "map[string]string", + "scheme": "`map[string]string`", "description": "The properties of the component", }, { @@ -324,7 +348,7 @@ export function ComponentEnv() { }, { "field": "summary", - "scheme": "map[string]string", + "scheme": "`map[string]string`", "description": "The summary of the component", }, { @@ -344,44 +368,258 @@ export function ComponentEnv() { }, { "field": "cost_per_minute", - "scheme": "float64", + "scheme": "`float64`", "description": "The cost per minute of the component" }, { "field": "cost_total_1d", - "scheme": "float64", + "scheme": "`float64`", "description": "The cost total 1d of the component" }, { "field": "cost_total_7d", - "scheme": "float64", + "scheme": "`float64`", "description": "The cost total 7d of the component" }, { "field": "cost_total_30d", - "scheme": "float64", + "scheme": "`float64`", "description": "The cost total 30d of the component" }, { "field": "created_by", - "scheme": "uuid", + "scheme": "`uuid`", "description": "Id of the person that created this component" }, { "field": "created_at", - "scheme": "time.Time", + "scheme": "`time.Time`", "description": "Created timestamp" }, { "field": "updated_at", - "scheme": "time.Time", + "scheme": "`time.Time`", "description": "Updated timestamp" }, { "field": "deleted_at", - "scheme": "time.Time", + "scheme": "`time.Time`", "description": "Deleted timestamp", } ]} /> -} \ No newline at end of file +} + +export function CheckEnv() { + return +} + +export function Uptime() { + return ( + + ) +} + +export function Latency() { + return ( + + ) +} + + +### Check Status + +| Field | Description | Schema | Optional | +| ------------ | ----------------------------------------------- | ----------- | -------- | +| `check_id` | The id of the check associated with this status | `uuid` | | +| `status` | The status of the check | `bool` | | +| `invalid` | Whether the check errored out | `bool` | | +| `time` | The time of the check | `string` | | +| `duration` | The duration of the check | `int` | | +| `message` | The success message of the check | `string` | | +| `error` | The error of the check in case of failure | `string` | | +| `created_at` | The created at of the check | ``time.Time`` | | + + +export function CheckStatus() { + return ( + + ) +} diff --git a/mission-control/docs/reference/notifications/template_vars.mdx b/mission-control/docs/reference/notifications/template_vars.mdx index fa9f626..03ae864 100644 --- a/mission-control/docs/reference/notifications/template_vars.mdx +++ b/mission-control/docs/reference/notifications/template_vars.mdx @@ -2,7 +2,11 @@ title: Template Variables --- -import { ConfigDBStateEnv, CheckHealthEnv, ConfigHealthEnv, ComponentHealthEnv, AgentEnv, ConfigItemEnv, ComponentEnv, CanaryEnv } from "./_env_vars.mdx" +import { + ConfigDBStateEnv, CheckHealthEnv, ConfigHealthEnv, ComponentHealthEnv, + AgentEnv, ConfigItemEnv, ComponentEnv, CanaryEnv, CheckEnv, CheckStatus, + Uptime, Latency +} from "./_env_vars.mdx" ### Config State Env @@ -16,14 +20,26 @@ import { ConfigDBStateEnv, CheckHealthEnv, ConfigHealthEnv, ComponentHealthEnv, ### Component Health Env -#### Agent +### Agent -#### Config Item +### Config Item -#### Component +### Component -#### Canary - \ No newline at end of file +### Canary + + +### Check + + +### CheckStatus + + +### Uptime + + +### Latency + \ No newline at end of file