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.Splunk SPL users
Splunk SPL users
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.ANSI SQL users
ANSI SQL users
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.Usage
Syntax
Parameters
| Name | Type | Description |
|---|---|---|
| expression | dynamic | The expression to check for boolean type. |
Returns
Returnstrue if the expression value is a boolean, false otherwise.
Use case examples
- Log analysis
- OpenTelemetry traces
- Security logs
Validate that a field contains boolean values before using it in boolean operations or filters.QueryRun in PlaygroundOutput
This example creates a boolean field and validates it using
| _time | uri | status | is_cached | cache_hit |
|---|---|---|---|---|
| Jun 24, 09:28:10 | /api/users | 200 | true | true |
isbool before using it in further boolean operations, ensuring type safety in your queries.List of related functions
- tobool: Converts a value to boolean. Use
toboolto convert values to boolean, andisboolto check if a value is already a boolean. - gettype: Returns the type of a value as a string. Use
gettypewhen you need to check for multiple types, andisboolwhen you only need to check for boolean. - isnull: Checks if a value is null. Use
isnullto check for null values, andisboolto check for boolean type.