Skip to content

Commit

Permalink
Merge branch 'main' into feat/mssql-db
Browse files Browse the repository at this point in the history
Signed-off-by: talboren <[email protected]>
  • Loading branch information
talboren authored Feb 20, 2024
2 parents 39b8027 + 035cf58 commit 01a482d
Show file tree
Hide file tree
Showing 96 changed files with 6,557 additions and 5,122 deletions.
Binary file added docs/images/rule-creation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rule-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"overview/keyconcepts",
"overview/usecases",
"overview/ruleengine",
{
"group": "Enrichments",
"pages": ["overview/enrichment/mapping"]
},
"overview/examples",
"overview/comparison"
]
Expand Down Expand Up @@ -168,7 +172,7 @@
"pages": ["workflows/examples/multi-step-alert"]
},
"workflows/state"
]
]
},
{
"group": "Keep API",
Expand Down Expand Up @@ -246,18 +250,14 @@
"cli/commands/workflow-run",
{
"group": "keep workflow runs",
"pages": [
"cli/commands/runs-logs",
"cli/commands/runs-list"
]
"pages": ["cli/commands/runs-logs", "cli/commands/runs-list"]
}
]
},
"cli/commands/cli-api",
"cli/commands/cli-config",
"cli/commands/cli-version",
"cli/commands/cli-whoami"

]
}
]
Expand Down
50 changes: 50 additions & 0 deletions docs/overview/enrichment/mapping.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "Alert Enrichment - Mapping"
---

# Alert Mapping and Enrichment

Keep's Alert Mapping and Enrichment feature provides a powerful mechanism for dynamically enhancing alert data by leveraging external data sources, such as CSV files. This feature allows for the matching of incoming alerts to specific records in a CSV file based on predefined attributes (matchers) and enriching those alerts with additional information from the matched records.

## Introduction

In complex monitoring environments, the need to enrich alert data with additional context is critical for effective alert analysis and response. Keep's Alert Mapping and Enrichment enables users to define rules that match alerts to rows in a CSV file, appending or modifying alert attributes with the values from matching rows. This process adds significant value to each alert, providing deeper insights and enabling more precise and informed decision-making.

## How It Works

1. **Rule Definition**: Users define mapping rules that specify which alert attributes (matchers) should be used for matching alerts to rows in a CSV file.
2. **CSV File Specification**: A CSV file is associated with each mapping rule. This file contains additional data that should be added to alerts matching the rule.
3. **Alert Matching**: When an alert is received, the system checks if it matches the conditions of any mapping rule based on the specified matchers.
4. **Data Enrichment**: If a match is found, the alert is enriched with additional data from the corresponding row in the CSV file.

## Core Concepts

- **Matchers**: Attributes within the alert used to identify matching rows within the CSV file. Common matchers include identifiers like `service` or `region`.
- **CSV File**: A structured file containing rows of data. Each column represents a potential attribute that can be added to an alert.
- **Enrichment**: The process of adding new attributes or modifying existing ones in an alert based on the data from a matching CSV row.

## Creating a Mapping Rule

To create an alert mapping and enrichment rule:

<Frame width="100" height="200">
<img height="10" src="/images/rule-creation.png" />
</Frame>

1. **Define the Matchers**: Specify which alert attributes will be used to match rows in the CSV file.
2. **Upload the CSV File**: Provide the CSV file containing the data for enrichment.
3. **Configure the Rule**: Set additional parameters, such as whether the rule should override existing alert attributes.

## Practical Example

Imagine you have a CSV file with columns representing different aspects of your infrastructure, such as `region`, `responsible_team`, and `severity_override`. By creating a mapping rule that matches alerts based on `service` and `region`, you can automatically enrich alerts with the responsible team and adjust severity based on the matched row in the CSV file.

## Best Practices

- **Keep CSV Files Updated**: Regularly update the CSV files to reflect the current state of your infrastructure and operational data.
- **Use Specific Matchers**: Define matchers that are unique and relevant to ensure accurate matching.
- **Monitor Rule Performance**: Review the application of mapping rules to ensure they are working as expected and adjust them as necessary.

<Frame width="100" height="200">
<img height="10" src="/images/rule-table.png" />
</Frame>
29 changes: 29 additions & 0 deletions examples/workflows/bash_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
workflow:
id: Resend-Python-service
description: Python Resend Mail
triggers:
- type: manual
owners: []
services: []
steps:
- name: run-script
provider:
config: '{{ providers.default-bash }}'
type: bash
with:
command: python3 test.py
timeout: 5
actions:
- condition:
- assert: '{{ steps.run-script.results.return_code }} == 0'
name: assert-condition
type: assert
name: trigger-resend
provider:
type: resend
config: "{{ providers.resend-test }}"
with:
_from: "[email protected]"
to: "[email protected]"
subject: "Python test is up!"
html: <p>Python test is up!</p>
15 changes: 15 additions & 0 deletions keep-ui/app/alerts/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import AlertsPage from "../alerts.client";

type PageProps = {
params: { id: string };
searchParams: { [key: string]: string | string[] | undefined };
};

export default function Page({ params }: PageProps) {
return <AlertsPage presetName={params.id} />;
}

export const metadata = {
title: "Keep - Alerts",
description: "Single pane of glass for all your alerts.",
};
12 changes: 6 additions & 6 deletions keep-ui/app/alerts/alert-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export default function AlertActions({
};

async function addOrUpdatePreset() {
const presetName = prompt("Enter new preset name");
if (presetName) {
const newPresetName = prompt("Enter new preset name");
if (newPresetName) {
const distinctAlertNames = Array.from(
new Set(selectedAlerts.map((alert) => alert.name))
);
Expand All @@ -107,18 +107,18 @@ export default function AlertActions({
Authorization: `Bearer ${session?.accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ name: presetName, options: options }),
body: JSON.stringify({ name: newPresetName, options: options }),
});
if (response.ok) {
toast(`Preset ${presetName} created!`, {
toast(`Preset ${newPresetName} created!`, {
position: "top-left",
type: "success",
});
presetsMutator();
clearRowSelection();
router.replace(`${pathname}?selectedPreset=${presetName}`);
router.replace(`/alerts/${newPresetName}`);
} else {
toast(`Error creating preset ${presetName}`, {
toast(`Error creating preset ${newPresetName}`, {
position: "top-left",
type: "error",
});
Expand Down
Loading

0 comments on commit 01a482d

Please sign in to comment.