Data types

Types are classifications that define the nature and operations of data, such as integers or strings. They help ensure that data is used appropriately and safely in a program, preventing type-related errors. In the NXLog language, simple types are basic data types that store a single value, like integers or strings. Composite types, on the other hand, can contain multiple values or complex data structures, such as arrays or key-value pairs in hashes.

Simple types

Unknown

This is a special type for values where the type cannot be determined at compile time and for uninitialized values. The undef literal and fields without a value also have an unknown type. The unknown type can also be thought of as "any" in the case of function and procedure API declarations.

Boolean

A boolean value is TRUE, FALSE or undefined. Note that an undefined value is not the same as a FALSE value.

Integer

An integer can hold a signed 64-bit value in addition to the undefined value. Floating point values are not supported.

String

A string is an array of characters in any character set. The binary type should be used for values where the NULL byte can also occur. An undefined string is not the same as an empty string. Strings have a limited length to prevent resource exhaustion problems, this is a compile-time value currently set to 1M.

Datetime

A datetime holds a microsecond, millisecond, and second value of time elapsed since the Epoch, and NXLog Agent can handle the corresponding value. It is always stored in UTC/GMT.

IP Address

The ipaddr type can store IP addresses in an internal format. This type is used to store both dotted-quad IPv4 addresses (for example, 192.168.1.1) and IPv6 addresses (for example, [2001:0db8:85a3:0:0:8a2e:0370:7334]).

Regular expression

A regular expression type can only be used with the =~ or !~ operators.

Binary

This type can hold an array of bytes.

Composite types

Array

This type is a container and it can hold an arbitrary number of values of any type supported by the NXLog language. The individual members are accessed by a non-negative integer type of index value. See Arrays for more information.

Hash

This type is a container and it can hold an arbitrary number of key-value pairs. The key is a string while the value is one of the value types supported by the NXLog language. The individual values can be accessed by the key strings. See Hashesfor more information.

Variadic arguments

This is a special type only used in function and procedure API declarations to indicate variadic arguments.

JSON string

A specific format of json-string.

JSON string is not yet a separate data type and is just a simple string. It was described separately to specify the string format.
JSON map

A specific format for json-string. Presents as an object description for specific json-array.