Mastering Log Cost Control: How to Drop Noisy Log Lines in Grafana Cloud Using Adaptive Logs Drop Rules
Learn to create Adaptive Logs drop rules in Grafana Cloud to filter noisy logs, reduce costs, and simplify log management with step-by-step instructions and common pitfalls.
Overview
Platform and observability teams often face a common headache: logs that add noise without value. Health check pings, forgotten DEBUG statements, or verbose INFO messages from rarely used services can bloat your logging costs and distract from real issues. Removing them traditionally required cumbersome infrastructure changes and coordination across teams—until now.
Adaptive Logs in Grafana Cloud introduces drop rules (currently in public preview), giving you a straightforward way to eliminate low-value logs before they ever hit Cloud Logs storage. This tutorial walks you through the concept, step-by-step creation, best practices, and common pitfalls—all with a focus on saving money and reducing noise without sacrificing visibility.
Prerequisites
Before diving into drop rules, ensure you have the following:
- A Grafana Cloud account with access to the Adaptive Logs feature (available in Pro and Enterprise plans).
- Permissions to create and manage drop rules (typically
AdminorEditorrole). - Basic familiarity with log labels (e.g.,
service,namespace) and log levels (DEBUG, INFO, WARN, ERROR). - Understanding of sampling concepts—drop rules can also sample logs at a percentage.
Step-by-Step Instructions
1. Understanding Drop Rules
A drop rule is a custom filter that matches incoming log lines based on criteria you define. Once matched, the rule applies a drop rate (0% to 100%). At 100%, all matching logs are discarded; at lower percentages, a random sample is kept. You can combine multiple conditions using log labels (e.g., service=nginx), log level, and line content (regex patterns).
Drop rules are evaluated in priority order (highest priority first). Once a rule matches, subsequent rules are not applied to that log line. This lets you create layered filtering, like dropping all DEBUG logs first, then sampling specific services.
2. Creating a Drop Rule
Follow these steps to create your first drop rule:
- Log in to your Grafana Cloud instance.
- Navigate to Adaptive Logs (usually under your stack’s Logs section or from the home menu).
- Click the Drop Rules tab, then New Drop Rule.
- Define the rule name (e.g., “Drop health check logs from production”).
- Set the priority (lower number = higher priority). Use 1 for critical rules.
- In the match section, specify conditions. For example:
- Labels:
service=health-checker - Log level:
INFO - Line content:
.*"status": "ok".*
- Labels:
- Set the Drop Percentage to 100 to discard all matches.
- Save the rule.
Here’s a conceptual JSON representation of the rule (though the UI handles it):
{
"name": "Drop health check INFO logs",
"priority": 1,
"match": {
"labels": "service=health-checker",
"level": "INFO",
"line_content": ".*\"status\": \"ok\".*"
},
"drop_rate": 100
}
3. Example Use Cases
- Drop all DEBUG logs: Set
level=DEBUG, drop rate 100. - Sample repetitive logs from a batch job: Use
service=batch-processorwith a drop rate of 90% (keep 10%). - Target a noisy producer: Combine
namespace=stagingwith a line content regex like.*verbose.*and drop at 100%.
4. Order of Evaluation (Exemptions → Drop Rules → Patterns)
When a log line arrives in Grafana Cloud, it passes through three stages:
- Exemptions: Logs that match exemption rules (e.g., for compliance) pass through untouched—even if a drop rule would match.
- Drop Rules: Your custom rules are evaluated in priority order. The first match applies its drop rate.
- Patterns: Adaptive Logs’ intelligent optimization recommendations apply to any logs that weren’t exempted or dropped. These reduce volume further by grouping similar lines.
This design ensures that critical logs are never lost, while known noise is removed early.
Common Mistakes
- Ignoring priority order: If you have a broad rule (e.g., drop all DEBUG logs) with priority 10 and a specific rule (e.g., keep DEBUG logs from security service) with priority 5, the broad rule will never run because the specific rule matches first. Plan priority carefully.
- Overly aggressive drop rates: Setting 100% drop on a rule that accidentally matches important logs can cause data loss. Start with a low drop rate (e.g., 50%) and monitor before increasing.
- Forgetting to test with a small sample: Use the Preview feature (if available) or temporarily set a low drop rate to verify the rule matches as intended.
- Mixing label, level, and content without understanding: Conditions are AND-ed together. A log must satisfy all conditions to match. If you only want to target by level, leave label and content blank.
- Not documenting rules: Drop rules can accumulate. Add descriptions to each rule so your team understands why it exists.
Summary
Drop rules in Adaptive Logs give you a powerful, self-service way to eliminate noisy log lines before they are ingested, reducing costs and operational overhead. By understanding the evaluation order, crafting precise conditions, and using sampling wisely, you can maintain a clean, cost-effective log pipeline. Start with the built-in preview, test on a subset, and gradually apply rules across your services. Monitor your log volume in the Grafana Cloud console to see the impact—and then fine-tune as needed.