exp
exp is useful when you work with log-transformed data and need to recover the original scale. For example, if you have computed the average of log-transformed latencies and want the geometric mean on the original scale, apply exp to the result. You can also use exp to model exponential growth or decay in metric data.
Usage#
Syntax#
exp(x)Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
x |
real | Yes | The exponent value. |
Returns#
The base-e exponential of x: e^x.
Example#
Use exp to compute the geometric mean of request durations from log-transformed values.
Query
['sample-http-logs']
| where req_duration_ms > 0
| summarize geometric_mean = exp(avg(log(req_duration_ms))) by bin(_time, 1h)
| project _time, geometric_meanOutput
| _time | geometric_mean |
|---|---|
| 2024-11-14 10:00:00 | 85.3 |
| 2024-11-14 11:00:00 | 92.7 |
| 2024-11-14 12:00:00 | 78.1 |
List of related functions#
- log: Returns the natural logarithm. Use it as the inverse of
expor to apply log transformations before aggregating. - exp2: Returns 2^x. Use it instead of
expwhen working with binary (base-2) scales. - exp10: Returns 10^x. Use it instead of
expwhen working with base-10 (decibel or order-of-magnitude) scales. - pow: Raises any base to a power. Use it when the base isn't e, 2, or 10.
- sqrt: Returns the square root. Use it for simpler power-of-0.5 calculations rather than
exp(0.5 * log(x)).
Other query languages#
Splunk SPL users
In Splunk SPL, exp() works the same way: it computes e^x for a numeric argument.
Splunk example
| eval result = exp(log_value)APL equivalent
['sample-http-logs']
| extend result = exp(log_value)ANSI SQL users
In ANSI SQL, EXP() is a standard function with identical semantics.
SQL example
SELECT EXP(log_value) AS result FROM logsAPL equivalent
['sample-http-logs']
| extend result = exp(log_value)