PostHog / PostHog/posthog

Alerting - Allow SQL based alerts

Open
#46,019 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Feature request

Is your feature request related to a problem?

I want to be able to trigger Slack alerts based on anomalies in our data. The current functionality is quite limited, as we can trigger alerts only based on trends. The event I want to alert on has high fluctuation based on the day of the week. Therefore, I'd like to calculate averages for the same day of the week and notify if there is an offset. I can easily do the calculations in SQL, but unfortunately it's not possible to create alerts based on it.

Describe the solution you'd like

Be able to trigger alerts based on SQL queries in a similar fashion to, for example, preset offers:
https://docs.preset.io/docs/alerts-reports

Describe alternatives you've considered

I tried various ways to achieve the goal, including workflows or trying to be more sophisticated with the trends feature, but with no success.

Debug info
- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing trend-based alerting behavior and the linked Preset alerts documentation to understand the requested SQL model. Done would mean defining and implementing SQL-triggered Slack alerts that can compare query results and notify on the requested condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
analytics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.