Type Checking Functions

Learn about the IsBool, IsDouble, IsInt, IsList, IsMap, IsString OTTL converter functions.

These type checking converters return a boolean value indicating whether the input is of the specified type. They are useful for conditional processing based on data types.

Syntax: IsBool|IsDouble|IsInt|IsList|IsMap|IsString(value)

  • value: the field to check the type of

Note: JSON numeric values are parsed as floats/doubles by default. IsInt() will return false for JSON numbers like 42, even though they appear to be integers. Use IsDouble() to check for JSON numeric values.

Input

{
	"_type": "log",
	"body": {
		"bool_val": true,
		"int_val": 42,
		"float_val": 3.14,
		"string_val": "text",
		"list_val": [1, 2, 3],
		"map_val": {"key": "value"},
		"run": 26
	},
	"resource": {...},
	"timestamp": 1727750400000
}

Statement

set(body["is_bool"], IsBool(body["bool_val"]))
set(body["is_int"], IsInt(body["int_val"]))
set(body["is_double"], IsDouble(body["float_val"]))
set(body["is_string"], IsString(body["string_val"]))
set(body["is_list"], IsList(body["list_val"]))
set(body["is_map"], IsMap(body["map_val"]))

Output

{
	"_type": "log",
	"body": {
		"bool_val": true,
		"int_val": 42,
		"float_val": 3.14,
		"string_val": "text",
		"list_val": [1, 2, 3],
		"map_val": {"key": "value"},
		"is_bool": true,
		"is_int": false,
		"is_double": true,
		"is_string": true,
		"is_list": true,
		"is_map": true,
		"run": 26
	},
	"resource": {...},
	"timestamp": 1727750400000
}

Each type checking function correctly identified the type of its corresponding field. Note that is_int is false because JSON numbers are parsed as doubles.