Network functions

  • Latest Dynatrace
  • Reference

Functions related to IP addresses.

ip

You can use this function to create an IP address.

Syntax

ip(expression)

Parameters

Returns

The data type of the returned value is ip.

Examples

Example 1
data record(value = "127.0.0.1"),
record(value = "2001:0db8:0000:0000:0000:8a2e:0370:7334"),
record(value = "2001:db8::8a2e:370:7334"),
record(value = "::1"),
record(value = "317.0.0.1") // invalid IPv4
| fieldsAdd ip(value)

Query result:

ipIn

This function returns a Boolean which indicates if at least one IP address of the first parameter can be found in the following ones - the same behavior as the in() function.

Syntax

ipIn(needle_expressions, haystack_expressions...)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "127.0.0.1", b = "127.0.0.1"),
record(a = "127.0.0.1", b = "127.0.0.1/8"),
record(a = "127.0.0.1/8", b = "127.0.0.1"),
record(a = "127.0.0.1/8", b = "127.0.0.1/16"),
record(a = array("127.0.0.1", "10.0.0.1"), b = "127.0.0.1"),
record(a = array("127.0.0.1", "10.0.0.1"), b = array("127.0.0.1/8", "10.0.0.2"))
| fieldsAdd ipIn(a, b)

Query result:

Example 2
data record(a = ip("127.0.0.1"), b = ip("127.0.0.1")),
record(a = array(ip("127.0.0.1"), ip("10.0.0.1")), b = ip("127.0.0.1")),
record(a = array(ip("127.0.0.1"), ip("10.0.0.1")), b = array(ip("127.0.0.1"), ip("10.0.0.2")))
| fieldsAdd ipIn(a, b)

Query result:

Example 3
data record(a = ip("127.0.0.1"), b = "127.0.0.1/8"),
record(a = array("127.0.0.1", ip("10.0.0.1")), b = "127.0.0.1"),
record(a = array("127.0.0.1", ip("10.0.0.1")), b = array("127.0.0.1/8", ip("10.0.0.2")))
| fieldsAdd ipIn(a, b)

Query result:

ipIsLinkLocal

Checks if an IP address is a link-local IP address.

Syntax

ipIsLinkLocal(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "169.254.0.0"),
record(a = "169.254.255.255"),
record(a = "169.255.0.0")
| fieldsAdd ipIsLinkLocal(a)

Query result:

ipIsLoopback

Checks if an IP address is a loopback IP address.

Syntax

ipIsLoopback(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "127.0.0.1"),
record(a = "10.0.0.1"),
record(a = "::1")
| fieldsAdd ipIsLoopback(a)

Query result:

ipIsPrivate

Checks if an IP address is a private IP address.

Syntax

ipIsPrivate(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "127.0.0.1"),
record(a = "10.0.0.1"),
record(a = "::1"),
record(a = "172.16.1.1"),
record(a = "1.2.3.4")
| fieldsAdd ipIsPrivate(a)

Query result:

ipIsPublic

Checks if an IP address is a public IP address.

Syntax

ipIsPublic(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "1.2.3.4"),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:7334"),
record(a = "10.0.0.1"),
record(a = "::1")
| fieldsAdd ipIsPublic(a)

Query result:

ipMask

Masks an IP address with given bits (optional parameter for IPv6 addresses).

Syntax

ipMask(expression, maskBits [, ipv6MaskBits])

Parameters

Returns

The data type of the returned value is ip.

Examples

Example 1
data record(a = "127.1.2.3"),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:7334")
| fieldsAdd ipMask(a, 8),
ipMask(a, 16, ipv6MaskBits: 32)

Query result:

isIp

Checks if an expression is an IPv4/v6 address.

Syntax

isIp(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "127.0.0.1"),
record(a = "127.0.0."),
record(a = toIp("127.0.0.1")),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:7334"),
record(a = toIp("2001:0db8:0000:0000:0000:8a2e:0370:7334")),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:")
| fieldsAdd isIp(a)

Query result:

isIpV4

Checks if an expression is an IPv4 address.

Syntax

isIpV4(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "127.0.0.1"),
record(a = "127.0.0."),
record(a = toIp("127.0.0.1")),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:7334"),
record(a = toIp("2001:0db8:0000:0000:0000:8a2e:0370:7334")),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:")
| fieldsAdd isIpV4(a)

Query result:

isIpV6

Checks if an expression is an IPv6 address.

Syntax

isIpV6(expression)

Parameters

Returns

The data type of the returned value is boolean.

Examples

Example 1
data record(a = "127.0.0.1"),
record(a = "127.0.0."),
record(a = toIp("127.0.0.1")),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:7334"),
record(a = toIp("2001:0db8:0000:0000:0000:8a2e:0370:7334")),
record(a = "2001:0db8:0000:0000:0000:8a2e:0370:")
| fieldsAdd isIpV6(a)

Query result:

IP address mathematical operations

  • IP address + numeric

  • IP address + IP address

  • IP address - numeric

  • IP address - IP address

Examples

Example 1
data record(a = toIp("127.0.0.10"), b = toIp("10.0.0.1"))
| fieldsAdd a + b, a - b, a + 1, a - 1

Query result:

Related tags
Dynatrace Platform