Commit fc9db19
feat: add Grafana integration and alert system (#67)
* feat: add Grafana integration and alert system
Add a complete alert system with notification channels (webhook, email,
Feishu), configurable alert rules (budget, error rate, latency, quota),
and alert history tracking.
Add Grafana integration for syncing alert rules as Prometheus-based
Grafana alerts via the Provisioning API. When Grafana is connected,
the built-in alert engine defers to Grafana for evaluation.
Restructure frontend navigation: model configuration moves to /models
(Providers + Registry sub-nav), system settings moves to /settings
(Alerts + Grafana sub-nav) as separate sidebar items.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address PR review comments
- Fix PromQL label selector syntax (no leading/trailing commas)
- Add fetch timeouts (AbortSignal.timeout) to all external HTTP calls
- Add ON DELETE CASCADE to alert_history FK referencing alert_rules
- Deduplicate grafanaConnectionQueryOptions (reuse from use-settings hook)
- Add default case to dispatchToChannel switch statement
- Fix duplicate listApiKeys() call in evaluateQuota
- Add missing i18n key pages.settings.grafana.Testing
- Fix wrong i18n key reference in grafana-settings-page.tsx
- Clear datasourceUid on connection test failure
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: escape HTML in email alerts and add apiKeyId filter to quota PromQL
- Add escapeHtml() helper and apply to all dynamic fields in email template
- Add apiKeyId label selector to quota PromQL when a specific key is configured
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(alerts): correct Feishu webhook signature algorithm
Per Feishu docs, the signature must use `timestamp\nsecret` as the HMAC key
and sign an empty string, then Base64-encode the result. The previous
implementation incorrectly used `secret` as key, `timestamp\nsecret` as
data, and hex-encoded the output.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: use Buffer for hex encoding and add graceful shutdown
- Replace manual Array.from hex encoding with Buffer.from().toString("hex")
- Add SIGINT/SIGTERM handlers to stop alert engine and server on shutdown
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent f823a58 commit fc9db19
37 files changed
Lines changed: 8644 additions & 77 deletions
File tree
- backend
- drizzle
- meta
- src
- adapters/upstream
- api/admin
- db
- services
- utils
- frontend/src
- components
- app
- ui
- hooks
- i18n/locales
- pages/settings
- routes
- models
- settings
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments