Documentation Index
Fetch the complete documentation index at: https://axiom.co/docs/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Thecase function evaluates a sequence of condition-result pairs and returns the value of the first condition that evaluates to true. Use it to map raw values to human-readable labels, define alert severity tiers, or apply multi-way branching in a single expression instead of chaining multiple iff calls.
case is particularly useful when you need to classify log events into categories, route spans into latency buckets, or assign risk scores to requests based on several attributes at once.
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 SPL, the
case() function inside eval takes alternating condition-value pairs. APL’s case works the same way: provide pairs of (condition, value) followed by a fallback value.ANSI SQL users
ANSI SQL users
SQL uses
CASE WHEN condition THEN value ... ELSE fallback END. APL’s case is functionally equivalent but uses a compact function-call syntax. The last argument serves as the ELSE value.Usage
Syntax
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| conditionn | bool | Yes | Expression to evaluate. APL tests conditions in order and returns the result paired with the first true condition. |
| resultn | scalar | Yes | Value returned when the preceding condition is the first to evaluate to true. All result expressions must be of the same type. |
| nothingMatchedResult | scalar | Yes | Value returned when no condition evaluates to true. Must be the same type as the result expressions. |
Returns
The value paired with the first condition that evaluates totrue, or nothingMatchedResult if no condition is true.
Use case examples
- Log analysis
- OpenTelemetry traces
- Security logs
Classify HTTP responses by status code to summarize request outcomes.QueryRun in PlaygroundOutput
The query assigns a human-readable label to each request based on its HTTP status code, then counts how many requests fall into each category.
| severity | count_ |
|---|---|
| success | 8412 |
| other | 1203 |
| not found | 534 |
| server error | 182 |