Basic Structure
match: One or more matchers that identify target metricskeep: Boolean (trueto keep,falseto drop)
Unlike log policies, metric policies don’t support percentage sampling or rate
limiting. The
keep value is a simple boolean.Matchers
Matchers identify which metrics a policy applies to. When a policy has multiple matchers, all must match (AND logic).Metric Fields
Match on well-known metric fields:Metric Type
Match on metric type:Aggregation Temporality
Match on how metrics report aggregated values:Datapoint Attributes
Match on data point attributes (dimensions/labels):Resource Attributes
Match on resource attributes:Scope Attributes
Match on instrumentation scope attributes:Match Types
Exact Match
Match the exact string value:Regex Match
Match using RE2 regular expressions:Exists Match
Match on field presence:Negation
Invert any match withnegate:
Policy Precedence
When multiple policies match the same metric,keep: false takes precedence
over keep: true.
Examples
Drop Debug Metrics
Drop System Load Metrics
Drop Histogram Metrics
Drop by Datapoint Attribute
Drop by Service
Drop High-Cardinality Metrics
Keep Only Specific Metrics
Using negation to drop everything except what you want:Combined Conditions
Common Use Cases
Cost Reduction
Drop metrics you don’t query:- Debug and internal metrics
- Per-request ID dimensions (high cardinality)
- Redundant system metrics
- Metrics from test/dev environments
Cardinality Control
High-cardinality metrics (many unique label combinations) are expensive. Drop metrics with:- Unique request IDs as labels
- User IDs as labels
- Timestamps as labels
- Unbounded string values as labels
Compliance
Drop metrics that might contain sensitive information:- Metrics with PII in labels
- Metrics from sensitive services
- Internal topology information
Best Practices
- Start with observability: Know what you’re dropping before you drop it
- Use exact matches when possible: Faster than regex
- Target high-volume metrics: Focus on metrics that cost the most
- Be careful with negation: It makes it easy to drop metrics you meant to keep
- Test in staging: Verify policies before production deployment
Next Steps
Log Filter
Filter logs
Log Transform
Transform log data