log10

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

Use the log10 function in APL to compute the common (base-10) logarithm of a positive numeric value. The function returns null for zero or negative inputs.

log10 is useful for order-of-magnitude analysis. Because each unit increase in log10(x) represents a tenfold increase in x, you can use it to compare values that span multiple orders of magnitude, build decibel-scale metrics, or bucket data by powers of ten. It's also the basis for recovering values with exp10.

Usage

Syntax

log10(x)

Parameters

NameTypeRequiredDescription
xrealYesA positive real number (x > 0).

Returns

  • The base-10 logarithm of x.
  • null if x is negative, zero, or can't be converted to a real value.

Example

Use log10 to express request durations on a base-10 log scale where each integer step represents an order of magnitude.

Query

['sample-http-logs']
| where req_duration_ms > 0
| extend log10_duration = log10(req_duration_ms)
| project _time, id, req_duration_ms, log10_duration

Run in Playground

Output

_timeidreq_duration_mslog10_duration
2024-11-14 10:00:00user-11.00.0000
2024-11-14 10:01:00user-2100.02.0000
2024-11-14 10:02:00user-310000.04.0000
  • exp10: Returns 10^x. Use it as the inverse of log10 to recover original values.
  • log: Returns the natural logarithm. Use it when you want the mathematically natural base rather than base-10.
  • log2: Returns the base-2 logarithm. Use it for binary-scale analysis.
  • pow: Raises a value to a power. Use it to compute powers of 10 directly as an alternative to exp10.
  • round: Rounds a value. Use it after log10 to bucket values by integer order of magnitude.

Other query languages