Skip to content

Commit 587db4e

Browse files
committed
feat: Add support for new messaging backends: Microsoft Teams, PagerDuty, and Generic Webhook
- Updated register_backends.py to include Microsoft Teams, PagerDuty, and Generic Webhook backends. - Implemented Microsoft Teams backend with configuration form and alert sending functionality. - Created PagerDuty backend for incident management with customizable severity and service name. - Developed Generic Webhook backend for sending alerts to any HTTP endpoint with flexible configuration options. - Enhanced backend verification and import handling in register_backends.py.
1 parent bae4b46 commit 587db4e

File tree

6 files changed

+1238
-38
lines changed

6 files changed

+1238
-38
lines changed

src/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LABEL org.opencontainers.image.version="0.0.0"
4040
# Extended Labels
4141
LABEL org.opencontainers.image.base.name="bugsink/bugsink:${BUGSINK_VERSION}"
4242
LABEL com.bauer-group.bugsink.version="${BUGSINK_VERSION}"
43-
LABEL com.bauer-group.features="jira-cloud,github-issues"
43+
LABEL com.bauer-group.features="jira-cloud,github-issues,microsoft-teams,pagerduty,webhook"
4444

4545
# =============================================================================
4646
# Copy Custom Messaging Backends
@@ -56,6 +56,9 @@ ENV BUGSINK_SITE_PACKAGES=/usr/local/lib/python3.12/site-packages
5656
# Copy backend files to Bugsink's service_backends directory
5757
COPY backends/jira_cloud.py ${BUGSINK_SITE_PACKAGES}/alerts/service_backends/jira_cloud.py
5858
COPY backends/github_issues.py ${BUGSINK_SITE_PACKAGES}/alerts/service_backends/github_issues.py
59+
COPY backends/microsoft_teams.py ${BUGSINK_SITE_PACKAGES}/alerts/service_backends/microsoft_teams.py
60+
COPY backends/pagerduty.py ${BUGSINK_SITE_PACKAGES}/alerts/service_backends/pagerduty.py
61+
COPY backends/webhook.py ${BUGSINK_SITE_PACKAGES}/alerts/service_backends/webhook.py
5962

6063
# Copy the initialization patch script
6164
COPY patches/register_backends.py /tmp/register_backends.py

src/backends/README.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Bugsink Custom Messaging Backends
22

3-
Custom Messaging-Backends für Bugsink v2 zur Integration mit Issue-Tracking-Systemen.
3+
Custom Messaging-Backends für Bugsink v2 zur Integration mit Issue-Tracking-Systemen und Alerting-Plattformen.
44

55
**Kompatibilität:** Bugsink v2.x
66

@@ -10,12 +10,15 @@ Custom Messaging-Backends für Bugsink v2 zur Integration mit Issue-Tracking-Sys
1010
|---------|--------------|-------|
1111
| Jira Cloud | Erstellt Bug-Tickets in Jira Cloud | `jira_cloud.py` |
1212
| GitHub Issues | Erstellt Issues in GitHub Repositories | `github_issues.py` |
13+
| Microsoft Teams | Sendet Adaptive Cards an Teams Channels | `microsoft_teams.py` |
14+
| PagerDuty | Erstellt Incidents für On-Call Alerting | `pagerduty.py` |
15+
| Webhook (Generic) | Sendet JSON an beliebige HTTP Endpoints | `webhook.py` |
1316

1417
## Wie es funktioniert
1518

1619
Diese Backends werden beim Docker-Build automatisch in das Bugsink-Image integriert:
1720

18-
1. **COPY**: Backend-Dateien werden nach `/app/alerts/service_backends/` kopiert
21+
1. **COPY**: Backend-Dateien werden nach `/usr/local/lib/python3.12/site-packages/alerts/service_backends/` kopiert
1922
2. **PATCH**: `register_backends.py` patcht `alerts/models.py` zur Registrierung
2023
3. **CLEANUP**: Das Patch-Skript wird nach der Ausführung entfernt
2124

@@ -27,18 +30,9 @@ Diese Backends werden beim Docker-Build automatisch in das Bugsink-Image integri
2730
- Methode `clear_failure_status()` zum Zurücksetzen
2831
- **Task-System**: `snappea` (nicht Celery) - Import: `from snappea.decorators import shared_task`
2932
- **Transaktionen**: `from bugsink.transaction import immediate_atomic` für DB-Writes in Tasks
30-
- **Backend-Registrierung**: Via `get_alert_service_kind_choices()` und `get_alert_service_backend_class()` in `alerts/models.py`
33+
- **Backend-Registrierung**: Via `kind` choices und `get_backend()` in `alerts/models.py`
3134
- **ConfigForm**: Verwendet `config = kwargs.pop("config", None)` Pattern
32-
33-
## PR-Kompatibilität
34-
35-
Diese Backend-Dateien sind so strukturiert, dass sie für einen PR ins Bugsink-Repo verwendet werden können:
36-
37-
1. **Speicherort**: `alerts/service_backends/jira_cloud.py` bzw. `github_issues.py`
38-
2. **Registrierung**: Ergänzungen in `alerts/models.py`:
39-
- Import der Backend-Klassen
40-
- Tuple in `get_alert_service_kind_choices()`: `("jira_cloud", "Jira Cloud")`
41-
- If-Block in `get_alert_service_backend_class()`: `if kind == "jira_cloud": return JiraCloudBackend`
35+
- **Config-Speicherung**: JSON im `config` TextField
4236

4337
## Konfiguration
4438

@@ -66,6 +60,36 @@ Diese Backend-Dateien sind so strukturiert, dass sie für einen PR ins Bugsink-R
6660
- **Labels**: Optional, z.B. `bug,bugsink`
6761
- **Assignees**: Optional, z.B. `username1,username2`
6862

63+
### Microsoft Teams
64+
65+
1. **Incoming Webhook erstellen**: Channel > Connectors > Incoming Webhook
66+
67+
2. **In Bugsink konfigurieren**:
68+
- **Webhook URL**: Die generierte Webhook-URL
69+
- **Channel Name**: Optional, für Anzeige
70+
- **Mention Users**: Optional, E-Mail-Adressen für @-Mentions
71+
- **Theme Color**: Hex-Farbe für die Card (Standard: `d63333`)
72+
73+
### PagerDuty
74+
75+
1. **Integration erstellen**: Service > Integrations > Events API v2
76+
77+
2. **In Bugsink konfigurieren**:
78+
- **Routing Key**: 32-Zeichen Integration Key
79+
- **Default Severity**: `critical`, `error`, `warning`, oder `info`
80+
- **Service Name**: Optional, Quellname (Standard: `Bugsink`)
81+
- **Include Link**: Link zum Issue im Incident
82+
83+
### Webhook (Generic)
84+
85+
1. **In Bugsink konfigurieren**:
86+
- **Webhook URL**: HTTP(S) Endpoint
87+
- **HTTP Method**: `POST`, `PUT`, oder `PATCH`
88+
- **Secret Header**: Optional, Header-Name für Auth (z.B. `X-Webhook-Secret`)
89+
- **Secret Value**: Optional, Wert für den Secret Header
90+
- **Custom Headers**: Optional, JSON-Objekt mit zusätzlichen Headers
91+
- **Include Full Payload**: Vollständige Issue-Details senden
92+
6993
## Trigger-Events
7094

7195
| Event | Beschreibung |
@@ -87,3 +111,18 @@ Diese Backend-Dateien sind so strukturiert, dass sie für einen PR ins Bugsink-R
87111
- Prüfe das Repository-Format: `owner/repo`
88112
- Stelle sicher, dass der Token `repo` oder `issues:write` Permissions hat
89113
- Verifiziere, dass Issues im Repository aktiviert sind
114+
115+
### Microsoft Teams: "Bad Request"
116+
117+
- Prüfe, ob die Webhook-URL noch gültig ist
118+
- Webhooks können ablaufen oder deaktiviert werden
119+
120+
### PagerDuty: "Invalid Routing Key"
121+
122+
- Der Routing Key muss exakt 32 Zeichen haben
123+
- Stelle sicher, dass die Integration aktiv ist
124+
125+
### Webhook: Timeout/Connection Error
126+
127+
- Prüfe, ob der Endpoint erreichbar ist
128+
- Verifiziere Firewall-Regeln und Netzwerkzugriff

0 commit comments

Comments
 (0)