Skip to main content

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

SettingTypeRequiredDescription
keystringYesThe field path to check. Supports dot notation for nested fields. Use * to check all keys.
valuenumberYesThe threshold value to compare against.
notbooleanNoIf 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:

{
"type_id": "less_than",
"config": {
"key": "priority",
"value": 3
}
}

Matches:

{"priority": 1}
{"priority": 2}
{"priority": 2.5}

Does not match:

{"priority": 3}
{"priority": 5}
{"priority": 10}

Small Payload Handling

Route small payloads for faster processing:

{
"type_id": "less_than",
"config": {
"key": "size_bytes",
"value": 1024
}
}

Matches:

{"size_bytes": 512}
{"size_bytes": 100}
{"size_bytes": 0}

Error Rate Check

Filter for acceptable error rates:

{
"type_id": "less_than",
"config": {
"key": "error_rate",
"value": 0.01
}
}

Matches:

{"error_rate": 0.005}
{"error_rate": 0}
{"error_rate": 0.0099}

Nested Field Check

Check nested numeric values:

{
"type_id": "less_than",
"config": {
"key": "stats.retry_count",
"value": 3
}
}

Matches:

{"stats": {"retry_count": 0}}
{"stats": {"retry_count": 2}}

Greater Than or Equal (using not)

Match values at or above a minimum:

{
"type_id": "less_than",
"config": {
"key": "score",
"value": 60,
"not": true
}
}

Matches:

{"score": 60}
{"score": 75}
{"score": 100}

Does not match:

{"score": 59}
{"score": 0}

Remaining Quota Check

Check if quota is running low:

{
"type_id": "less_than",
"config": {
"key": "remaining_quota",
"value": 100
}
}

Matches:

{"remaining_quota": 50}
{"remaining_quota": 0}

Common Patterns

Fast Path for Small Requests

Route small requests to optimized processing:

{
"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:

{
"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):

{
"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:

{
"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:

{
"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):

{
"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 TypeBehavior
NumbersStandard numeric comparison
Numeric stringsParsed and compared as numbers ("42" works like 42)
Non-numeric stringsReturns false
BooleansNot supported (returns false)
ArraysNot supported (use array index to access elements)
NullReturns false
MissingReturns false (or true if not is set)

Comparison Reference

ConditionResult 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