ip()

Converts a string to an IP address type.

Syntax

ip(EXPR)
Required Parameters
EXPR
Expression that returns a string to be converted to an IP address. The argument type must be one of a string, int, or long.

Description

When evaluating an expression, it works as follows:

  • When it is null, the expression returns null.
  • Even when it cannot be converted to an integer, the expression also returns null.
  • If any other type is passed as an argument, the expression converts it into a string and then attempts to convert it to an IP address.

IP addresses are one of the basic data types of Logpresso. The IP address starts with "/" and can represent both ipv4 and ipv6 addresses.

Usage

json "{}" | eval ip=ip("1.2.3.4") => /1.2.3.4

json "{}" | eval ip=ip("::1") => /0:0:0:0:0:0:0:1

json "{}" | eval ip=ip(4294967295) => /255.255.255.255

json "{}" | eval ip=ip(-1062731775) => /192.168.0.1

json "{}" | eval ip=ip("invalid") => null

json "{}" | eval ip=ip(null) => null