Skip to main content
Use the isbool function to check whether an expression evaluates to a boolean value. This is helpful when you need to validate data types, filter boolean values, or handle type checking in conditional logic. You typically use isbool when working with dynamic or mixed-type data where you need to verify that a value is actually a boolean before performing boolean operations or conversions.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk, you can use isbool() function or check if a field contains boolean values. In APL, isbool provides a direct way to check if an expression is a boolean type.
... | eval is_boolean = if(isbool(field), 1, 0)
In standard SQL, you use CASE statements with type checking or IS NULL checks, but there’s no direct boolean type checker. In APL, isbool provides a straightforward way to check if a value is a boolean.
SELECT CASE WHEN field IN (0, 1, TRUE, FALSE) THEN 1 ELSE 0 END AS is_boolean FROM logs;

Usage

Syntax

isbool(expression)

Parameters

NameTypeDescription
expressiondynamicThe expression to check for boolean type.

Returns

Returns true if the expression value is a boolean, false otherwise.

Use case examples

Validate that a field contains boolean values before using it in boolean operations or filters.Query
['sample-http-logs']
| extend is_cached = case(
    ['status'] == '200', true,
    ['status'] == '304', true,
    1 == 1, false
)
| where isbool(is_cached)
| extend cache_hit = is_cached == true
| project _time, ['uri'], ['status'], is_cached, cache_hit
Run in PlaygroundOutput
_timeuristatusis_cachedcache_hit
Jun 24, 09:28:10/api/users200truetrue
This example creates a boolean field and validates it using isbool before using it in further boolean operations, ensuring type safety in your queries.
  • tobool: Converts a value to boolean. Use tobool to convert values to boolean, and isbool to check if a value is already a boolean.
  • gettype: Returns the type of a value as a string. Use gettype when you need to check for multiple types, and isbool when you only need to check for boolean.
  • isnull: Checks if a value is null. Use isnull to check for null values, and isbool to check for boolean type.