The Alert resource allows you to create and manage alerts that notify you when metrics exceed or fall below specified thresholds in PostHog.
Example Usage#
Basic Alert#
Low Signup Alert#
Percentage Change Alert#
Daily Check Alert#
Weekend-Skipping Alert#
Series-Specific Alert#
Resource Properties#
Required Arguments#
insight(number): Numeric ID of the insight this alert monitorsthresholdType(string): Type of threshold -"absolute"for fixed values or"percentage"for relative changessubscribedUsers(number[]): List of user IDs to notify when the alert fires
Optional Arguments#
name(string): Alert nameenabled(boolean): Whether alert is enabled (default: true)thresholdLower(number): Lower bound of the threshold - alert fires when value goes below thisthresholdUpper(number): Upper bound of the threshold - alert fires when value goes above thiscalculationInterval(string): How often to check -"hourly","daily","weekly", or"monthly"conditionType(string): Condition type -"absoluteValue","relativeIncrease", or"relativeDecrease"seriesIndex(number): Index of the trend series to monitor (0-based)checkOngoingInterval(boolean): Whether to check the ongoing (incomplete) intervalskipWeekend(boolean): Whether to skip checking the alert on weekends
Attributes#
- All configured properties
Threshold Types#
Absolute Value#
Fixed numeric thresholds:
Percentage Change#
Relative change thresholds:
Calculation Intervals#
Hourly#
Check metrics every hour:
Daily#
Check once per day:
Weekly#
Check once per week:
Monthly#
Check once per month:
Best Practices#
1. Use Descriptive Names#
2. Set Appropriate Thresholds#
3. Notify the Right People#
Common Use Cases#
Error Rate Monitoring#
Conversion Drop Detection#
Traffic Spike Alert#
Troubleshooting#
Alert Not Firing#
Issue: Alert doesn't trigger when threshold is exceeded
Solution:
- Verify the alert is enabled
- Check calculation interval matches expectation
- Confirm insight ID is correct
- Ensure threshold values are set appropriately
Wrong Users Notified#
Issue: Incorrect users receiving alerts
Solution:
- Verify user IDs are correct numeric values
- Check user IDs in PostHog user settings
- Update
subscribedUsersarray with correct IDs
Getting User IDs#
To find PostHog user IDs:
- Go to PostHog Settings → Team
- View team members list
- Note the numeric user ID (visible in URLs or API responses)
Or use the PostHog API:
Getting Insight IDs#
To find insight IDs:
- Open the insight in PostHog
- Check the URL:
/insights/12345- the number is the ID - Or use the PostHog API to list insights