Logstash Filter Plugins
You'll learn how to use Logstash filter plugins to enrich, transform, and clean your log data before it reaches storage.
What Are Filter Plugins?
After Logstash parses your logs (like we did with Grok patterns), filter plugins let you modify, add, or remove fields from those events. Think of them as a production line where raw parsed logs get polished, stamped with extra information, and packaged perfectly before storage.
While Grok extracts structure, filters enhance meaning and usability.
Essential Filter Plugins
mutate
The Swiss Army knife for field manipulation. Change data types, rename fields, replace values, or add new fields:
filter {
mutate {
convert => { "response_time" => "integer" }
rename => { "src_ip" => "source_ip" }
remove_field => [ "temporary_field" ]
uppercase => [ "status_code" ]
}
}
date
Parses timestamp strings into Logstash's internal @timestamp field, crucial for time-based queries:
filter {
date {
match => [ "log_timestamp", "yyyy-MM-dd HH:mm:ss" ]
target => "@timestamp"
}
}
geoip
Enriches IP addresses with geographic location data—city, country, coordinates:
filter {
geoip {
source => "client_ip"
target => "geo"
}
}
Now your logs know where requests came from, enabling geographic dashboards.
Other Useful Filters
- drop: Discard unwanted events entirely
- clone: Duplicate events for multiple processing paths
- fingerprint: Generate unique IDs for deduplication
Why This Matters
Raw logs are data. Enriched logs are intelligence. Filters transform timestamps into searchable dates, IPs into maps, and messy strings into structured fields ready for analysis.
Key Takeaway: Logstash filter plugins transform parsed logs into enriched, queryable events by adding context (geoip), normalizing formats (date), and cleaning data (mutate)—turning raw text into actionable intelligence.