CIDR filter plugin
Matches IP addresses against one or more CIDR ranges and lets you take action on matches (for example tag internal traffic, drop known-bad ranges, or route events by network).
- Package:
logstash-filter-cidr - Coverage source: default/bundled
- Official catalog entry: Yes
Plugin overview
cidr is used in the Logstash filter stage. Checks IP addresses against one or more network ranges.
Typical use cases
- Transform fields before indexing to keep schema and naming consistent.
- Prepare high-quality fields for alerts, dashboards, and downstream pipelines.
Input and output behavior
- Flow: processes matching events and mutates fields/tags within the same event.
- Input: works on events that match your surrounding
ifconditions. - Output: updates the current event in place unless configured otherwise.
- Important options:
address,address_field,network,network_path.
Options
Required
- No required plugin-specific options.
Optional
address(type: array; default:[]) — List of IP addresses to check against the configured networks.address_field(type: string; default: none) — Field whose value is used as the IP to check (alternative toaddress).network(type: array; default:[]) — List of CIDR blocks to match against (for example10.0.0.0/8).network_path(type: a valid filesystem path; default: none) — Path to a file containing one CIDR block per line, reloaded at the configured interval.refresh_interval(type: number; default:600) — Seconds between reloads whennetwork_pathis used.separator(type: string; default:\n) — Character used to split multiple CIDR values when loading from a file.
Example configuration
filter {
cidr {
address => [ "%{[client][ip]}" ]
network => [ "10.0.0.0/8", "192.168.0.0/16", "172.16.0.0/12" ]
add_tag => [ "internal_network" ]
}
}Common options configuration
All Logstash filter plugins support these shared options:
add_field(type: hash; default:{}) — Adds fields when the filter succeeds. Supports dynamic field names and values.add_tag(type: array; default:[]) — Adds one or more tags when the filter succeeds.enable_metric(type: boolean; default:true) — Enables or disables metric collection for this plugin instance.id(type: string; default:none) — Sets an explicit plugin instance ID for monitoring and troubleshooting.periodic_flush(type: boolean; default:false) — Calls the filter flush method at regular intervals.remove_field(type: array; default:[]) — Removes fields when the filter succeeds. Supports dynamic field names.remove_tag(type: array; default:[]) — Removes tags when the filter succeeds.
filter {
cidr {
add_field => { "pipeline_stage" => "parsed" }
add_tag => ["parsed", "logstash_filter"]
enable_metric => true
id => "my_filter_instance"
periodic_flush => false
remove_field => ["tmp_field"]
remove_tag => ["temporary"]
}
}Apply in Logit.io
- Open your stack in Logit.io and navigate to Logstash Pipelines.
- In the
filter { ... }section, add acidrblock. - Save your pipeline changes, then restart the Logstash pipeline if prompted.
- Send sample events and verify parsed/enriched fields in OpenSearch Dashboards.
Validation checklist
- Confirm the
cidrblock compiles without syntax errors. - Verify expected new/updated fields exist in sample documents.
- Verify unexpected fields are not removed unless explicitly configured.
- Confirm tags added on success/failure align with your alerting and routing rules.
Troubleshooting
- If events are unchanged, verify your filter condition (
if ...) matches incoming events. - If the pipeline fails to start, validate braces/quotes and retry with a minimal filter block.
- If throughput drops, reduce expensive operations and test with representative sample volume.
References
- GitHub package:
logstash-filter-cidr(opens in a new tab) - Canonical catalog: /log-management/ingestion-pipeline/logstash-filters-reference