Filters events using CIDR subnets. Used for both IPv4 and IPv6 addresses.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
column | string | optional[a] | When file and column parameters are used together, it loads the subnet list from the given .csv . | |
field [b] | string | required | Specifies the field that the CIDR expression runs against. | |
file | string | optional[a] | When file and column parameters are used together, it loads the subnet list from the given .csv . | |
negate (deprecated) | boolean | optional[a] | false | This parameter is deprecated. Use the !cidr(...) negation instead to allow only addresses that are not in the given subnet to pass through (see cidr() Examples) or to allow events without the assigned field to pass through. (deprecated in 1.100.0) |
subnet | array of strings | optional[a] | Specifies the list of IP ranges the CIDR expression matches with. | |
[a] Optional parameters use their default value unless explicitly set. |
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
field
can be omitted; the following forms of this function are equivalent:logscale Syntaxcidr("value")
and:
logscale Syntaxcidr(field="value")
These examples show basic structure only.
Hide negatable operation for this function
Negatable Function OperationThis function is negatable, implying the inverse of the result. For example:
logscale Syntax!cidr()
Or:
logscale Syntaxnot cidr()
For more information, see Negating the Result of Filter Functions.
cidr()
Examples
Click
next to an example below to get the full details.Check if Field Contains Valid IP Address
Check if field contains valid IP address using the cidr()
function
Query
case {
cidr("address", subnet=["0.0.0.0/0", "::/0"]) | ip := address;
*
}
Introduction
The cidr()
function can be used to filter
events using CIDR subnets and is used for both IPv4 and IPv6
addresses. In this example, the cidr()
function is used to check if a field contains valid IP addresses,
both IPv4 and IPv6.
Step-by-Step
Starting with the source repository events.
- logscale
case { cidr("address", subnet=["0.0.0.0/0", "::/0"]) | ip := address; * }
Checks if a field contains valid IP addresses, both IPv4 and IPv6, and then assigns that address to the field ip.
If you only want to check for valid IPv4 adresses, use:
cidr("address", subnet="0.0.0.0/0")
If you only want to check for valid IPv6 adresses, use:
cidr("address", subnet="::/0")
Event Result set.
Summary and Results
The query is used to check for valid IP addresses.
Filter Events Using CIDR Subnets - Example 1
Filter events using CIDR subnets to limit search to an IP within an IP range
Query
cidr(ipAddress, subnet="192.0.2.0/24")
Introduction
The cidr()
function can be used to filter
events using CIDR subnets and is used for both IPv4 and IPv6
addresses. In this example, the cidr()
function is used to match events where an IP is within a given IP
range.
Step-by-Step
Starting with the source repository events.
- logscale
cidr(ipAddress, subnet="192.0.2.0/24")
Matches events for which the ipAddress field is in the IP range 192.0.2.0/24.
Event Result set.
Summary and Results
The query is used to search on specific subnets within the network, optimizing query performance. The search will only be performed on the IP addresses that fall in the range of the specified subnet filter.
Filter Events Using CIDR Subnets - Example 2
Filter events using CIDR subnets to limit search to two specific IP ranges
Query
cidr(ipAddress, subnet=["192.0.2.0/24", "203.0.113.0/24"])
Introduction
The cidr()
function can be used to filter
events using CIDR subnets and is used for both IPv4 and IPv6
addresses. In this example, the cidr()
function is used to match events within two IP ranges.
Step-by-Step
Starting with the source repository events.
- logscale
cidr(ipAddress, subnet=["192.0.2.0/24", "203.0.113.0/24"])
Matches events for which the ipAddress field is in the IP range 192.0.2.0/24 or 203.0.113.0/24.
Event Result set.
Summary and Results
The query is used to search on specific subnets within the network, uptimizing query performance. The search will only be performed on the IP addresses that fall in the range of the specified subnet filters.
Filter Events Using CIDR Subnets - Example 3
Filter events using CIDR subnets to match attributes listed in an uploaded cidrfile.csv
Query
cidr(field=SRC, file="cidrfile.csv", column="cidr-block")
Introduction
The cidr()
function can be used to filter
events using CIDR subnets and is used for both IPv4 and IPv6
addresses. In this example, the cidr()
function is used to match events for which the
SRC attributes is one of
those listed in the uploaded file
cidrfile.csv
with the subnets in the column
cidr-block.
Step-by-Step
Starting with the source repository events.
- logscale
cidr(field=SRC, file="cidrfile.csv", column="cidr-block")
Matches events for which the
SRC
field is one of those listed in the uploaded filecidrfile.csv
with the subnets in the column cidr-block. Event Result set.
Summary and Results
The query is used to search on specific subnets within the network, uptimizing query performance. The search will only be performed on the IP addresses that fall in the range of the specified subnet filter.
Filter Events Using CIDR Subnets - Example 4
Filter events using CIDR subnets with negation to match events not in a given IP range
Query
!cidr(ipAddress, subnet="192.0.2.0/24")
Introduction
The cidr()
function can be used to filter
events using CIDR subnets and is used for both IPv4 and IPv6
addresses. In this example, the cidr()
function is used with a negation to match events for which the
ipAddress
attributes is not
in a given IP range.
Step-by-Step
Starting with the source repository events.
- logscale
!cidr(ipAddress, subnet="192.0.2.0/24")
Matches events for which the ipAddress field is not in the IP range 192.0.2.0/24.
Event Result set.
Summary and Results
The query is used to search on specific subnets within the network, uptimizing query performance. The search will only be performed on the IP addresses that does not fall in the range of the specified subnet filter.