Detect anomalies in observation patterns. Alert when metrics deviate significantly from trailing averages.
Computes trailing mean and standard deviation for a given metric
from the observation_stream, then identifies observations that fall
beyond the configured sigma threshold (z-score based anomaly detection).
WHEN TO USE:
- Monitoring for unusual audience patterns (sudden spikes or drops in face count)
- Detecting equipment anomalies (confidence drops indicating sensor issues)
- Identifying unusual commerce or vehicle patterns
- Finding outlier moments that may indicate events, incidents, or opportunities
RETURNS:
- anomalies: Array of anomalous observations with:
- observation_id, device_id, venue_type, observed_at
- metric_value: The observed value
- z_score: How many standard deviations from the mean
- direction: 'above' or 'below' the mean
- payload: Full observation payload for context
- baseline: { mean, stddev, sample_count, lookback_hours }
- suggested_next_queries: Follow-up queries to investigate anomalies
EXAMPLE:
User: "Are there any unusual audience patterns at retail venues?"
anomaly_detect({
metric: "face_count",
venue_type: "retail",
lookback_hours: 24,
threshold_sigma: 2.0
})
User: "Detect anomalies in vehicle counts at this screen"
anomaly_detect({
metric: "vehicle_count",
screen_id: "507f1f77bcf86cd799439011",
lookback_hours: 48,
threshold_sigma: 2.5
})