Logstreem
Scalar functions

Scalar functions

Casts, conditionals, maths and type checks — everything that works on one value.

Scalar functions take values and return values. They appear inside where, extend, project and aggregation arguments.

Casts

FunctionReturnsNote
tostring(v)stringNever fails
toint(v)integer or nullNull when unparseable — pair with isnotnull()
todouble(v)float or null
tobool(v)boolean or nullAccepts true/false/1/0
todatetime(v)datetime or nullRFC 3339 or unix

Conditionals

FunctionDoes
iff(cond, a, b)Ternary
case(c1, v1, c2, v2, …, default)First matching condition wins
coalesce(a, b, …)First non-null
isnull(v) / isnotnull(v)Null test
isempty(v)Null or empty string
Bucketing with case
read top to bottom
1['api-gateway-prod']
2| extend tier = case(
3 latency < 100, "fast",
4 latency < 1000, "acceptable",
5 "slow")
6| summarize count() by tier, service
7| order by count_ desc

Maths

FunctionDoes
round(v, digits)Rounds to N decimal places
floor(v) / ceiling(v)Rounds down / up
abs(v)Absolute value
log(v) / log10(v) / exp(v)Logs and exponent
sqrt(v) / pow(v, n)Root and power
bin(v, step)Rounds down to a multiple of step — works on numbers and datetimes

Integer division truncates

errors / requests on two integers gives 0. Force a float: 100.0 * errors / requests. This is the single most common wrong-looking result in LSQL.