Basic Structure
match: One or more matchers that identify target logskeep: What to do with matching logs
Matchers
Matchers identify which logs a policy applies to. When a policy has multiple matchers, all must match (AND logic).Log Fields
Match on well-known log fields:| Field | Description |
|---|---|
body | The log message content |
severity_text | Severity level as text (DEBUG, INFO, WARN, ERROR, etc.) |
trace_id | Associated trace ID |
span_id | Associated span ID |
event_name | Event name for event logs |
Log Attributes
Match on log record attributes:Resource Attributes
Match on resource attributes (service name, host, etc.):Scope Attributes
Match on instrumentation scope:Match Types
Exact Match
Match the exact string value:Regex Match
Match using RE2 regular expressions:^prefix- Starts withsuffix$- Ends withword1.*word2- Contains both words in order(option1|option2)- Either option\\d+- One or more digits
Exists Match
Match on field presence:exists: false to match when a field is absent.
Negation
Invert any match withnegate:
Keep Values
Thekeep field determines what happens to matching logs.
Drop All
- Debug and trace logs in production
- Health check logs
- Known noisy log patterns
Keep All
Percentage Sampling
- High-volume events where you don’t need every instance
- Cost reduction on repetitive logs
Rate Limiting
100/s- 100 per second1000/m- 1000 per minute
- Burst protection
- Capping runaway log sources
Policy Precedence
When multiple policies match the same log, the most restrictive action wins:none(drop) beats everything- Lower percentages beat higher percentages
- Rate limits are evaluated independently
keep: 50% and Policy B says keep: none, the log is
dropped.
Examples
Drop Debug Logs
Drop Health Checks
Sample by Service
Rate Limit Noisy Service
Drop by Attribute Presence
Combine Multiple Conditions
Keep Everything Except
Usingnegate to keep only important logs:
Best Practices
- Start broad, then narrow: Begin with service-level policies, then add event-specific ones
- Use regex sparingly: Exact matches are faster than regex
- Combine policies: Multiple simple policies are easier to manage than one complex policy
- Document intent: Use descriptive names and IDs
- Test first: Verify policies in a staging environment before production