# Greater Than Checks if a numeric value is greater than a specified threshold. ## Overview The `greater_than` condition evaluates whether a field's numeric value exceeds a specified threshold. This is essential for threshold-based routing, alerting on metric values, filtering by numeric criteria, and implementing tiered processing. ## Use Cases - **Alerting**: Route high-severity events or metrics exceeding thresholds - **Tiered Processing**: Handle large orders, high-value transactions differently - **Performance Monitoring**: Filter for slow response times or high error rates - **Resource Management**: Route based on size, count, or usage metrics ## Configuration | Setting | Type | Required | Description | | ------- | ------- | -------- | -------------------------------------------------------------------------------------------- | | `key` | string | Yes | The field path to check. Supports dot notation for nested fields. Use `*` to check all keys.| | `value` | number | Yes | The threshold value to compare against. | | `not` | boolean | No | If `true`, inverts the condition (matches if value is NOT greater than threshold, i.e., less than or equal). | ## Examples ### Basic Threshold Check Route events with high severity: ```json { "type_id": "greater_than", "config": { "key": "severity", "value": 7 } } ``` **Matches:** ```json {"severity": 8} {"severity": 10} {"severity": 7.5} ``` **Does not match:** ```json {"severity": 7} {"severity": 5} {"severity": 0} ``` ### Response Time Monitoring Filter slow requests: ```json { "type_id": "greater_than", "config": { "key": "response_time_ms", "value": 1000 } } ``` **Matches:** ```json {"response_time_ms": 1500} {"response_time_ms": 2000} {"response_time_ms": 1000.1} ``` **Does not match:** ```json {"response_time_ms": 1000} {"response_time_ms": 500} ``` ### Nested Field Check Check values in nested objects: ```json { "type_id": "greater_than", "config": { "key": "metrics.error_rate", "value": 0.05 } } ``` **Matches:** ```json {"metrics": {"error_rate": 0.10}} {"metrics": {"error_rate": 0.051}} ``` ### Less Than or Equal (using `not`) Match values at or below a threshold: ```json { "type_id": "greater_than", "config": { "key": "priority", "value": 3, "not": true } } ``` **Matches:** ```json {"priority": 3} {"priority": 2} {"priority": 1} ``` **Does not match:** ```json {"priority": 4} {"priority": 5} ``` ### High-Value Transaction Route large transactions: ```json { "type_id": "greater_than", "config": { "key": "amount", "value": 10000 } } ``` **Matches:** ```json {"amount": 15000} {"amount": 10000.01} ``` ### Array Index Check Check values at specific array positions: ```json { "type_id": "greater_than", "config": { "key": "scores.0", "value": 90 } } ``` **Matches:** ```json {"scores": [95, 85, 80]} {"scores": [100]} ``` ## Common Patterns ### Multi-Tier Alerting Route based on severity tiers: **Critical alerts (severity > 8):** ```json { "operator": "and", "conditions": [ {"type_id": "equals", "config": {"key": "type", "value": "alert"}}, {"type_id": "greater_than", "config": {"key": "severity", "value": 8}} ] } ``` **Warning alerts (severity > 5 and <= 8):** ```json { "operator": "and", "conditions": [ {"type_id": "equals", "config": {"key": "type", "value": "alert"}}, {"type_id": "greater_than", "config": {"key": "severity", "value": 5}}, {"type_id": "greater_than", "config": {"key": "severity", "value": 8, "not": true}} ] } ``` ### Performance SLA Monitoring Route requests violating SLA: ```json { "operator": "or", "conditions": [ {"type_id": "greater_than", "config": {"key": "latency_ms", "value": 500}}, {"type_id": "greater_than", "config": {"key": "error_count", "value": 0}} ] } ``` ### Large Payload Handling Route oversized payloads for special processing: ```json { "operator": "and", "conditions": [ {"type_id": "greater_than", "config": {"key": "payload_size_bytes", "value": 1048576}}, {"type_id": "equals", "config": {"key": "content_type", "value": "application/json"}} ] } ``` ### Resource Usage Alerts Alert on high resource usage: ```json { "operator": "or", "conditions": [ {"type_id": "greater_than", "config": {"key": "cpu_percent", "value": 90}}, {"type_id": "greater_than", "config": {"key": "memory_percent", "value": 85}}, {"type_id": "greater_than", "config": {"key": "disk_percent", "value": 95}} ] } ``` ### Range Check (Between Two Values) Route values within a range (e.g., 50 < value <= 100): ```json { "operator": "and", "conditions": [ {"type_id": "greater_than", "config": {"key": "score", "value": 50}}, {"type_id": "greater_than", "config": {"key": "score", "value": 100, "not": true}} ] } ``` ## Best Practices 1. **Use appropriate precision**: Consider floating-point precision when setting thresholds. 2. **Combine with `less_than` for ranges**: Use both conditions to define numeric ranges. 3. **Document threshold values**: Make it clear why specific thresholds were chosen. 4. **Consider boundary conditions**: Remember that `greater_than` is exclusive (`>` not `>=`). 5. **Use `not` for inclusive bounds**: `greater_than` with `not: true` gives you `<=`. ## Type Handling | Data Type | Behavior | |-----------|----------| | Numbers | Standard numeric comparison | | Numeric strings | Parsed and compared as numbers (`"42"` works like `42`) | | Non-numeric strings | Returns false | | Booleans | Not supported (returns false) | | Arrays | Not supported (use array index to access elements) | | Null | Returns false | | Missing | Returns false (or true if `not` is set) | ## Comparison Reference | Condition | Result for value=7, threshold=5 | |-----------|--------------------------------| | `greater_than` (value: 5) | `true` (7 > 5) | | `greater_than` (value: 5, not: true) | `false` (7 <= 5 is false) | | `greater_than` (value: 7) | `false` (7 > 7 is false) | | `greater_than` (value: 10) | `false` (7 > 10 is false) | ## Limitations - Only works with numeric values - Non-numeric fields return `false` - No support for string comparison (use `equals` or `contains`) - Exclusive comparison only (use `not` for inclusive bounds) ## Troubleshooting **Condition not matching:** - Verify the field contains a numeric value (numeric strings like `"42"` also work) - Check if the field exists (missing fields return `false`) - Confirm the threshold value is correct **Unexpected matches:** - Check for floating-point precision issues - Verify the field path is correct **Boundary issues:** - Remember `greater_than` is exclusive (`>`, not `>=`) - Use `not: true` if you need `<=` behavior - Combine with `less_than` for range checks