isnull

This page explains how to use the isnull function in APL.

The isnull function evaluates its argument and returns true if the argument is null. Use this function to identify missing data, filter out incomplete records, or validate that optional fields are absent.

Usage

Syntax

isnull(value)

Parameters

NameTypeRequiredDescription
valuescalarYesThe value to check for null.

Returns

Returns true if the value is null, otherwise returns false. Note that empty strings return false because they're not null.

Use case examples

Identify HTTP requests with missing duration information to assess data quality and completeness.

Query

['sample-http-logs']
| extend missing_duration = isnull(req_duration_ms)
| summarize total_requests = count(),
            missing_duration_count = countif(missing_duration),
            missing_percentage = round(100.0 * countif(missing_duration) / count(), 2) by status
| sort by missing_duration_count desc
| limit 10

Run in Playground

Output

statustotal_requestsmissing_duration_countmissing_percentage
50012341239.97
2008765870.99
4042341230.98

This query identifies the percentage of requests missing duration data by status code, helping assess logging infrastructure reliability and identify potential issues.

Find traces with missing duration information to identify instrumentation problems.

Query

['otel-demo-traces']
| extend null_duration = isnull(duration)
| where null_duration
| summarize incomplete_spans = count() by ['service.name'], kind
| sort by incomplete_spans desc
| limit 10

Run in Playground

Output

service.namekindincomplete_spans
product-catalogserver234
cartinternal123
checkoutclient89

This query identifies services with incomplete trace data, helping pinpoint instrumentation issues where duration information is not being captured properly.

Identify anonymous access attempts by finding requests without user identification.

Query

['sample-http-logs']
| extend anonymous = isnull(id)
| summarize total_failures = count(),
            anonymous_failures = countif(anonymous) by status, ['geo.country']
| extend anonymous_rate = round(100.0 * anonymous_failures / total_failures, 2)
| where anonymous_failures > 10
| sort by anonymous_failures desc
| limit 10

Run in Playground

Output

statusgeo.countrytotal_failuresanonymous_failuresanonymous_rate
401Unknown56734560.85
403Russia23418980.77
401China19815678.79

This query identifies patterns of anonymous failed access attempts by country, helping security teams detect automated attacks or scanning activity.

  • isnotnull: Returns true if a value isn't null. Use this for the inverse check of isnull.
  • isempty: Checks if a value is empty or null. Use this when you need to check for both null and empty strings.
  • coalesce: Returns the first non-null value from a list. Use this to provide default values for null fields.
  • gettype: Returns the type of a value. Use this to distinguish between null and other types.

Other query languages