IP and CIDR operators
FuseQL provides operators for working with IP addresses and CIDR notation, enabling network-level analysis of log data.
comparecidrprefix
Checks whether two IPv4 addresses share the same network prefix at a given CIDR prefix length. Returns true if both addresses fall within the same subnet, false otherwise. Use this to test whether a client IP belongs to a specific network range.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
A string field or literal containing the first IPv4 address to compare. |
|
Yes |
A string field or literal containing the second IPv4 address (typically the network base address). |
|
Yes |
An integer from 0 to 32 specifying the number of network bits to compare. |
|
Yes |
Name for the boolean output column. |
Example
Check whether two IP addresses fall within the same /24 subnet.
source="nginx"
| compareCIDRPrefix("10.20.15.214", "10.20.15.1", 24) as same_net
| count by same_net
| same_net | _count |
|---|---|
True |
198333 |
|
For example, |
getcidrprefix
Returns the network address (prefix) for an IPv4 address given a CIDR prefix length. The host bits are zeroed out to produce the network identifier. Use this to group IP addresses by subnet for traffic analysis or access-control auditing.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
A string field or literal containing a dot-decimal IPv4 address. |
|
Yes |
An integer from 0 to 32 specifying the number of network bits. |
|
Yes |
Name for the string output column. |
Example
Return the /16 network prefix for a known IPv4 address.
source="nginx"
| getCIDRPrefix("10.20.15.214", 16) as subnet
| count by subnet
| subnet | _count |
|---|---|
10.20.0.0 |
205729 |
|
|
ipv4tonumber
Converts an IPv4 address from dot-decimal notation to its equivalent 32-bit unsigned decimal integer. This is useful for numeric range comparisons, sorting IPs arithmetically, and subnet boundary calculations without string manipulation.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
A string field or literal containing a dot-decimal IPv4 address. |
|
Yes |
Name for the numeric output column. |
Example
Convert an IPv4 address to its 32-bit integer representation.
source="nginx"
| ipv4ToNumber("10.20.15.214") as ip_num
| min(ip_num) as min_ip, max(ip_num) as max_ip
| min_ip | max_ip |
|---|---|
169086934 |
169086934 |
|
The formula is: |
isprivateip
Checks whether an IPv4 address falls within a private (RFC 1918) address range. Returns true for addresses in the 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 ranges, and false for all other addresses. Use this operator to identify internal service-to-service traffic in your logs.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
A string field or literal containing an IPv4 address. |
|
Yes |
Name for the boolean output column. |
Example
Check whether an nginx client IP falls within a private (RFC 1918) range.
source="nginx"
| isPrivateIP("10.20.15.214") as is_private
| count by is_private
| is_private | _count |
|---|---|
True |
130532 |
|
|
ispublicip
Checks whether an IPv4 address is a public (routable) address. Returns false for addresses in RFC 1918 private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and other reserved ranges, and true for all other addresses. Use this operator to identify external traffic in logs.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
A string field or literal containing an IPv4 address. |
|
Yes |
Name for the boolean output column. |
Example
Check whether a specific IP address is public (routable on the internet).
source="nginx"
| isPublicIP("8.8.8.8") as is_public
| count by is_public
| is_public | _count |
|---|---|
True |
124365 |
|
|
isvalidip
Checks whether an IPv4 or IPv6 address string is syntactically valid. Returns true if the address conforms to the correct format and falls within the allowed range, false otherwise. Useful for validating IP fields extracted from log lines before passing them to other IP operators.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
A string field or literal containing an IPv4 or IPv6 address. |
|
Yes |
Name for the boolean output column. |
Example
Check whether an extracted IPv4 address is syntactically valid.
source="nginx"
| isValidIP("10.20.15.214") as valid_ip
| count by valid_ip
| valid_ip | _count |
|---|---|
True |
133504 |
|
|
maskfromcidr
Returns the IPv4 subnet mask string that corresponds to a given CIDR prefix length. The result is a dot-decimal string such as 255.255.255.0. Use this to display or compare subnet masks derived from CIDR notation.
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Yes |
An integer from 0 to 32 specifying the CIDR prefix length. |
|
Yes |
Name for the string output column. |
Example
Compute the subnet mask for a /24 network and count log lines.
source="nginx"
| maskFromCIDR(24) as mask
| count
| _count |
|---|
203641 |
|
Common results: |