feat: add empty Alerts Page + mock API behind feature flag
What does this PR do?
In the spirit of Trunk-Based Development, I am adding a boilerplate Alerts page + a mock API for it behind a feature flag.
https://github.com/langfuse/langfuse/issues/714
Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Chore (refactoring code, technical debt, workflow improvements)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactor (does not change functionality, e.g. code style improvements, linting)
- [ ] This change requires a documentation update
Mandatory Tasks
- [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
@flxwu is attempting to deploy a commit to the langfuse Team on Vercel.
A member of the Team first needs to authorize it.
PR Stack:
-
main- PR 1 https://github.com/langfuse/langfuse/pull/754
-
PR 2 👉 https://github.com/flxwu/langfuse/pull/3
- Graphite: https://app.graphite.dev/github/pr/flxwu/langfuse/3/
-
PR 3 👉 https://github.com/flxwu/langfuse/pull/4
- Graphite: https://app.graphite.dev/github/pr/flxwu/langfuse/4
-
PR 4 👉 https://github.com/flxwu/langfuse/pull/5
- Graphite: https://app.graphite.dev/github/pr/flxwu/langfuse/5/
State as of latest PR (https://github.com/flxwu/langfuse/pull/4):
Most important attributes of an Alert:
// Currently only COST_PER_USER is supported, we can add COST_PER_TRACE, TOKENS_PER_USER etc in the future.
alertMetric AlertMetric
// When this threshold is crossed, the alert will be fired
alertThreshold Float
// The webhook to call when the alert is triggered
triggerWebhookUrl String? @map("trigger_webhook_url")
We are now able to automatically trigger Alerts when their threshold is crossed:
- See all alerts from the database on the UI
- On every new generation, check whether we should trigger any of the alerts in the database
- If yes, we trigger the Alerts by calling their Webhook URL.
Showcase
https://www.loom.com/share/cb9c1c31ad67414ea9f43c2599086b76?sid=9cc52abe-8084-48ea-b931-671e6ac2a794
We can see that the total cost that triggered the alert was 1.57$: (on top is the webhook logging, bottom is the user consumption dashboard with date range all-time)
State as of https://github.com/flxwu/langfuse/pull/5
We are now able to add alerts through the UI:
https://www.loom.com/share/4bfc522ae511490cb256be3ca57df28d?sid=70da53b1-0b86-48bf-b66c-1ff37c693674
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.