Browse Source

Add CIDR_MATCH function

Abdon Pijpelink 2 years ago
parent
commit
b8e824d341
1 changed files with 17 additions and 0 deletions
  1. 17 0
      docs/reference/esql/esql-functions.asciidoc

+ 17 - 0
docs/reference/esql/esql-functions.asciidoc

@@ -6,6 +6,7 @@ these functions:
 
 * <<esql-abs>>
 * <<esql-case>>
+* <<esql-cidr_match>>
 * <<esql-concat>>
 * <<esql-date_format>>
 * <<esql-date_trunc>>
@@ -48,6 +49,22 @@ FROM employees
 | PROJECT first_name, last_name, type
 ----
 
+[[esql-cidr_match]]
+=== `CIDR_MATCH`
+
+Returns `true` if the provided IP is contained in one of the provided CIDR
+blocks. 
+
+`CIDR_MATCH` accepts two or more arguments. The first argument is the IP
+address of type `ip` (both IPv4 and IPv6 are supported). Subsequent arguments
+are the CIDR blocks to test the IP against.
+
+[source,esql]
+----
+FROM hosts
+| WHERE CIDR_MATCH(ip, "127.0.0.2/32", "127.0.0.3/32")
+----
+
 [[esql-concat]]
 === `CONCAT`
 Concatenates two or more strings.