Skip to content

Commit b1edff0

Browse files
authored
fix: on-failure in yaml definition (#4775)
1 parent 92861c1 commit b1edff0

30 files changed

+1372
-1122
lines changed

examples/workflows/planner_basic.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ workflow:
1313
with:
1414
title: "Keep HQ Task1"
1515
plan_id: "tAtCor_XPEmqTzVqTigCycgABz0K"
16-
on-failure:
17-
retry:
18-
count: 2
19-
interval: 2
16+
on-failure:
17+
retry:
18+
count: 2
19+
interval: 2
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
workflow:
2+
id: send-slack-message-on-failure
3+
name: Get alert root cause from OpenAI, notify if workflow fails
4+
description: Get alert root cause from OpenAI, notify if workflow fails
5+
triggers:
6+
- type: alert
7+
cel: alert.severity == "critical"
8+
on-failure:
9+
provider:
10+
type: slack
11+
config: "{{ providers.slack }}"
12+
with:
13+
channel: "<slack-channel-id>"
14+
# message will be injected from the workflow engine
15+
# e.g. "Workflow <workflow-id> failed with error: <error-message>"
16+
steps:
17+
- name: openai-step
18+
provider:
19+
config: "{{ providers.openai }}"
20+
type: openai
21+
with:
22+
prompt: |
23+
You are a very talented engineer that receives critical alert and reports back the root
24+
cause analysis. Here is the context: keep.json_dumps({{alert}}) (it is a JSON of the alert).
25+
In your answer, also provide the reason why you think it is the root cause and specify what your certainty level is that it is the root cause. (between 1-10, where 1 is low and 10 is high)
26+
actions:
27+
- name: slack-action
28+
provider:
29+
config: "{{ providers.slack }}"
30+
type: slack
31+
with:
32+
message: "{{steps.openai-step.results}}"

keep-ui/app/(keep)/workflows/[workflow_id]/workflow-providers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { CheckCircleIcon, XCircleIcon } from "@heroicons/react/24/outline";
77
import { DynamicImageProviderIcon } from "@/components/ui";
88
import { useFetchProviders } from "../../providers/page.client";
99
import { useRevalidateMultiple } from "@/shared/lib/state-utils";
10-
import { checkProviderNeedsInstallation } from "@/entities/workflows/lib/validation";
10+
import { checkProviderNeedsInstallation } from "@/entities/workflows/lib/validate-definition";
1111
import { Drawer } from "@/shared/ui/Drawer";
1212

1313
export const ProvidersCarousel = ({
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { Provider } from "@/shared/api/providers";
2+
3+
export const mockProviders: Provider[] = [
4+
{
5+
id: "clickhouse",
6+
type: "clickhouse",
7+
config: {},
8+
installed: true,
9+
linked: true,
10+
last_alert_received: "",
11+
details: {
12+
authentication: {},
13+
},
14+
display_name: "Mock Clickhouse Provider",
15+
can_query: true,
16+
query_params: ["query", "single_row"],
17+
can_notify: false,
18+
validatedScopes: {},
19+
tags: [],
20+
pulling_available: true,
21+
pulling_enabled: true,
22+
categories: [],
23+
coming_soon: false,
24+
health: false,
25+
},
26+
{
27+
id: "ntfy",
28+
type: "ntfy",
29+
config: {},
30+
installed: true,
31+
linked: true,
32+
can_query: false,
33+
can_notify: true,
34+
notify_params: ["message", "topic"],
35+
details: {
36+
authentication: {},
37+
},
38+
display_name: "Mock Ntfy Provider",
39+
validatedScopes: {},
40+
tags: [],
41+
pulling_available: true,
42+
pulling_enabled: true,
43+
last_alert_received: "",
44+
categories: [],
45+
coming_soon: false,
46+
health: false,
47+
},
48+
{
49+
id: "slack",
50+
type: "slack",
51+
config: {},
52+
installed: true,
53+
linked: true,
54+
last_alert_received: "",
55+
details: {
56+
authentication: {},
57+
},
58+
display_name: "Mock Slack Provider",
59+
can_query: false,
60+
can_notify: true,
61+
notify_params: ["message"],
62+
validatedScopes: {},
63+
tags: [],
64+
pulling_available: true,
65+
pulling_enabled: true,
66+
categories: [],
67+
coming_soon: false,
68+
health: false,
69+
},
70+
{
71+
id: "console",
72+
type: "console",
73+
config: {},
74+
installed: true,
75+
linked: true,
76+
last_alert_received: "",
77+
details: {
78+
authentication: {},
79+
},
80+
display_name: "Mock Console Provider",
81+
can_query: false,
82+
can_notify: true,
83+
notify_params: ["message"],
84+
validatedScopes: {},
85+
tags: [],
86+
pulling_available: true,
87+
pulling_enabled: true,
88+
categories: [],
89+
coming_soon: false,
90+
health: false,
91+
},
92+
];

0 commit comments

Comments
 (0)