Skip to content

Commit de190a1

Browse files
authored
Merge branch 'main' into Feat/Workflow-secrets
2 parents eb97e2c + 90ac0e4 commit de190a1

File tree

10 files changed

+198
-0
lines changed

10 files changed

+198
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,12 @@
590590
Zenduty
591591
</a>
592592
</td>
593+
<td align="center" width="150">
594+
<a href="https://docs.keephq.dev/providers/documentation/flashduty-provider" target="_blank">
595+
<img width="40" src="keep-ui/public/icons/flashduty-icon.png" alt="Flashduty"/><br/>
596+
Flashduty
597+
</a>
598+
</td>
593599
</tr>
594600
</table>
595601

docs/images/flashduty_1.png

237 KB
Loading

docs/images/flashduty_2.png

170 KB
Loading

docs/images/flashduty_3.png

142 KB
Loading

docs/mint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
"providers/documentation/dynatrace-provider",
160160
"providers/documentation/eks-provider",
161161
"providers/documentation/elastic-provider",
162+
"providers/documentation/flashduty-provider",
162163
"providers/documentation/gcpmonitoring-provider",
163164
"providers/documentation/gemini-provider",
164165
"providers/documentation/github-provider",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: "Flashduty"
3+
sidebarTitle: "Flashduty Provider"
4+
description: "Flashduty docs"
5+
---
6+
7+
![Flashduty](/images/flashduty_1.png)
8+
9+
## Inputs
10+
11+
The `notify` method of the Flashduty Provider takes the following inputs:
12+
13+
- `title (str)`: The title of Flashduty incident
14+
- `event_status (str)`: The status of the incident, one of: Info, Warning, Critical, Ok
15+
- `description (str)`: The description of Flashduty incident
16+
- `alert_key (str)`: Alert identifier, used to update or automatically recover existing alerts. If you're reporting a recovery event, this value must exist
17+
- `labels (dict)`: The labels of Flashduty incident
18+
19+
## Outputs
20+
21+
None.
22+
23+
## Integration Key Generation
24+
25+
The Flashduty gets integration key as an authentication method
26+
27+
1.Enter the Flashduty console, select Integration Center => Alert Events to enter the integration selection page
28+
29+
![Flashduty](/images/flashduty_2.png)
30+
31+
2.Select Keep integration
32+
3.Define a name for the current integration
33+
4.Configure default routing and select the corresponding channel
34+
5.Copy the integration Key to Keep
35+
6.Complete the integration configuration
36+
37+
![Flashduty](/images/flashduty_3.png)
38+
39+
## Useful Links
40+
41+
- https://docs.flashcat.cloud/en/flashduty/keep-alert-integration-guide?nav=01JCQ7A4N4WRWNXW8EWEHXCMF5
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
workflow:
2+
id: 9f33281e-abf6-4254-b763-611eed6614ec
3+
name: test_flashduty_workflow
4+
description: desc
5+
disabled: false
6+
triggers:
7+
- type: incident
8+
events:
9+
- created
10+
- updated
11+
- deleted
12+
consts: {}
13+
owners: []
14+
services: []
15+
steps: []
16+
actions:
17+
- name: flashduty-action
18+
provider:
19+
type: flashduty
20+
config: "{{ providers.default-flashduty }}"
21+
with:
22+
title: test title
23+
description: test description
24+
event_status: Info
25+
alert_key: 611eed6614ec
26+
labels:
27+
service: flashduty
28+
environment: dev
29+
30+
133 KB
Loading

keep/providers/flashduty_provider/__init__.py

Whitespace-only changes.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import dataclasses
2+
import pydantic
3+
import requests
4+
5+
from keep.contextmanager.contextmanager import ContextManager
6+
from keep.exceptions.provider_exception import ProviderException
7+
from keep.providers.base.base_provider import BaseProvider
8+
from keep.providers.models.provider_config import ProviderConfig
9+
10+
@pydantic.dataclasses.dataclass
11+
class FlashdutyProviderAuthConfig:
12+
"""Flashduty authentication configuration."""
13+
14+
integration_key: str = dataclasses.field(
15+
metadata= {
16+
"required": True,
17+
"description": "Flashduty integration key",
18+
"sensitive": True,
19+
}
20+
)
21+
22+
23+
class FlashdutyProvider(BaseProvider):
24+
"""Create incident in Flashduty."""
25+
26+
PROVIDER_DISPLAY_NAME = "Flashduty"
27+
PROVIDER_CATEGORY = ["Incident Management"]
28+
29+
def __init__(
30+
self, context_manager: ContextManager, provider_id: str, config: ProviderConfig
31+
):
32+
super().__init__(context_manager, provider_id, config)
33+
34+
def validate_config(self):
35+
self.authentication_config = FlashdutyProviderAuthConfig(
36+
**self.config.authentication
37+
)
38+
39+
def dispose(self):
40+
"""
41+
No need to dispose of anything, so just do nothing.
42+
"""
43+
pass
44+
45+
def _notify(
46+
self,
47+
title: str = "",
48+
event_status: str = "",
49+
description: str = "",
50+
alert_key: str = "",
51+
labels: dict = {}
52+
):
53+
"""
54+
Create incident Flashduty using the Flashduty API
55+
56+
https://docs.flashcat.cloud/en/flashduty/custom-alert-integration-guide?nav=01JCQ7A4N4WRWNXW8EWEHXCMF5
57+
58+
Args:
59+
title (str): The title of the incident
60+
event_status (str): The status of the incident, one of: Info, Warning, Critical, Ok
61+
description (str): The description of the incident
62+
alert_key (str): Alert identifier, used to update or automatically recover existing alerts. If you're reporting a recovery event, this value must exist.
63+
labels (dict): The labels of the incident
64+
"""
65+
66+
self.logger.info("Notifying incident to Flashduty")
67+
if not title:
68+
raise ProviderException("Title is required")
69+
if not event_status:
70+
raise ProviderException("Event status is required")
71+
72+
body = {
73+
"title": title,
74+
"event_status": event_status,
75+
"description": description,
76+
"alert_key": alert_key,
77+
"labels": labels,
78+
}
79+
80+
headers = {
81+
"Content-Type": "application/json",
82+
}
83+
resp = requests.post(
84+
url=f"https://api.flashcat.cloud/event/push/alert/standard?integration_key={self.authentication_config.integration_key}", json=body, headers=headers
85+
)
86+
assert resp.status_code == 200
87+
self.logger.info("Alert message notified to Flashduty")
88+
89+
90+
if __name__ == "__main__":
91+
# Output test messages
92+
import logging
93+
94+
logging.basicConfig(level=logging.INFO, handlers=[logging.StreamHandler()])
95+
context_manager = ContextManager(
96+
tenant_id="singletenant",
97+
workflow_id="test",
98+
)
99+
# Load environment variables
100+
import os
101+
102+
integration_key = os.environ.get("INTEGRATION_KEY")
103+
assert integration_key
104+
105+
# Initalize the provider and provider config
106+
config = ProviderConfig(
107+
description="Flashduty Output Provider",
108+
authentication={"integration_key": integration_key},
109+
)
110+
provider = FlashdutyProvider(
111+
context_manager, provider_id="flashduty-test", config=config
112+
)
113+
provider.notify(
114+
title="Test incident",
115+
event_status="Info",
116+
description="Test description",
117+
alert_key="1234567890",
118+
labels={"service": "10.10.10.10"},
119+
)
120+

0 commit comments

Comments
 (0)