# Less Than Checks if a numeric value is less than a specified threshold. ## Overview The `less_than` condition evaluates whether a field's numeric value is below a specified threshold. This is useful for filtering low-priority items, checking for values within acceptable ranges, and implementing minimum thresholds. ## Use Cases - **Low-Priority Filtering**: Route low-severity events differently - **Resource Optimization**: Handle small payloads or low-traffic requests - **Quota Management**: Check remaining quotas or limits - **Quality Gates**: Filter out items below minimum thresholds ## 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 less than threshold, i.e., greater than or equal). | ## Examples ### Basic Threshold Check Route low-priority events: ```json { "type_id": "less_than", "config": { "key": "priority", "value": 3 } } ``` **Matches:** ```json {"priority": 1} {"priority": 2} {"priority": 2.5} ``` **Does not match:** ```json {"priority": 3} {"priority": 5} {"priority": 10} ``` ### Small Payload Handling Route small payloads for faster processing: ```json { "type_id": "less_than", "config": { "key": "size_bytes", "value": 1024 } } ``` **Matches:** ```json {"size_bytes": 512} {"size_bytes": 100} {"size_bytes": 0} ``` ### Error Rate Check Filter for acceptable error rates: ```json { "type_id": "less_than", "config": { "key": "error_rate", "value": 0.01 } } ``` **Matches:** ```json {"error_rate": 0.005} {"error_rate": 0} {"error_rate": 0.0099} ``` ### Nested Field Check Check nested numeric values: ```json { "type_id": "less_than", "config": { "key": "stats.retry_count", "value": 3 } } ``` **Matches:** ```json {"stats": {"retry_count": 0}} {"stats": {"retry_count": 2}} ``` ### Greater Than or Equal (using `not`) Match values at or above a minimum: ```json { "type_id": "less_than", "config": { "key": "score", "value": 60, "not": true } } ``` **Matches:** ```json {"score": 60} {"score": 75} {"score": 100} ``` **Does not match:** ```json {"score": 59} {"score": 0} ``` ### Remaining Quota Check Check if quota is running low: ```json { "type_id": "less_than", "config": { "key": "remaining_quota", "value": 100 } } ``` **Matches:** ```json {"remaining_quota": 50} {"remaining_quota": 0} ``` ## Common Patterns ### Fast Path for Small Requests Route small requests to optimized processing: ```json { "operator": "and", "conditions": [ {"type_id": "less_than", "config": {"key": "payload_size", "value": 1000}}, {"type_id": "less_than", "config": {"key": "complexity_score", "value": 5}} ] } ``` ### Low-Priority Queue Route low-priority items separately: ```json { "operator": "and", "conditions": [ {"type_id": "less_than", "config": {"key": "priority", "value": 3}}, {"type_id": "equals", "config": {"key": "status", "value": "pending"}} ] } ``` ### Range Check (Between Two Values) Route values within a specific range (e.g., 0 <= value < 50): ```json { "operator": "and", "conditions": [ {"type_id": "less_than", "config": {"key": "score", "value": 0, "not": true}}, {"type_id": "less_than", "config": {"key": "score", "value": 50}} ] } ``` ### Minimum Threshold Enforcement Ensure values meet minimum requirements: ```json { "operator": "and", "conditions": [ {"type_id": "less_than", "config": {"key": "confidence", "value": 0.8, "not": true}}, {"type_id": "key_exists", "config": {"key": "prediction"}} ] } ``` This matches records where confidence >= 0.8. ### Resource Monitoring Alert on low resources: ```json { "operator": "or", "conditions": [ {"type_id": "less_than", "config": {"key": "disk_free_gb", "value": 10}}, {"type_id": "less_than", "config": {"key": "memory_available_mb", "value": 512}} ] } ``` ### Time-Based Filtering Filter recent events (timestamp in seconds): ```json { "type_id": "less_than", "config": { "key": "age_seconds", "value": 300 } } ``` ## Best Practices 1. **Use appropriate precision**: Consider floating-point precision when setting thresholds. 2. **Combine with `greater_than` for ranges**: Use both conditions to define numeric ranges. 3. **Remember exclusive comparison**: `less_than` is exclusive (`<`, not `<=`). 4. **Use `not` for inclusive bounds**: `less_than` with `not: true` gives you `>=`. 5. **Document threshold values**: Make it clear why specific thresholds were chosen. ## 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=3, threshold=5 | |-----------|--------------------------------| | `less_than` (value: 5) | `true` (3 < 5) | | `less_than` (value: 5, not: true) | `false` (3 >= 5 is false) | | `less_than` (value: 3) | `false` (3 < 3 is false) | | `less_than` (value: 1) | `false` (3 < 1 is false) | ## Limitations - Only works with numeric values - Non-numeric fields return `false` - No support for string comparison - 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 **Boundary issues:** - Remember `less_than` is exclusive (`<`, not `<=`) - Use `not: true` if you need `>=` behavior - Combine with `greater_than` for range checks **Zero value handling:** - Zero is a valid number and will be compared normally - `less_than` with value `0` matches negative numbers only