Arithmetic functions :: Kloudfuse Docs
Arithmetic functions
Arithmetic functions apply a mathematical operation to every sample value of the input vector, preserving all labels.
abs
Applies abs to every sample value of the input vector, preserving all labels. Absolute value of every sample.
Syntax
abs(<expr>)
Example
Measure how far the query-service goroutine count moved in 30 minutes, regardless of direction.
abs(delta(go_goroutines{app_kubernetes_io_name="query-service"}[30m]))
| Value |
|---|
| 1.678 |
| 1.119 |
| 0 |
| 0.3051 |
| 0.6102 |
ceil
Applies ceil to every sample value of the input vector, preserving all labels. Rounds every sample up to the nearest integer.
Syntax
ceil(<expr>)
Example
Round the Kloudfuse goroutine total up to the next thousand.
ceil(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}) / 1000)
| Value |
|---|
| 386 |
clamp_max
Applies clamp_max to every sample value of the input vector, preserving all labels. Limits every sample to a maximum.
Syntax
clamp_max(<expr>, <max>)
Example
Cap the Kloudfuse goroutine total at 10,000.
clamp_max(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}), 10000)
| Value |
|---|
| 10,000 |
clamp_min
Applies clamp_min to every sample value of the input vector, preserving all labels. Limits every sample to a minimum.
Syntax
clamp_min(<expr>, <min>)
Example
Treat any decrease in goroutines as zero, keeping only growth.
clamp_min(delta(go_goroutines{app_kubernetes_io_name="query-service"}[30m]), 0)
| Value |
|---|
| 0.5085 |
| 0 |
| 0 |
| 0.05085 |
| 0 |
clamp
Applies clamp to every sample value of the input vector, preserving all labels. Limits every sample to a min–max range.
Syntax
clamp(<expr>, <min>, <max>)
Example
Cap the Kloudfuse goroutine total at 10,000 and floor it at 0 — outliers no longer stretch the chart axis.
clamp(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}), 0, 10000)
| Value |
|---|
| 10,000 |
exp
Applies exp to every sample value of the input vector, preserving all labels. e raised to each sample value.
Syntax
exp(<expr>)
Example
Compute e^1 — the result is Euler’s number, ≈ 2.718.
exp(vector(1))
| Value |
|---|
| 2.718 |
floor
Applies floor to every sample value of the input vector, preserving all labels. Rounds every sample down to the nearest integer.
Syntax
floor(<expr>)
Example
Round the Kloudfuse goroutine total down to the previous thousand.
floor(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}) / 1000)
| Value |
|---|
| 385 |
ln
Applies ln to every sample value of the input vector, preserving all labels. Natural logarithm of every sample.
Syntax
ln(<expr>)
Example
Take the natural log of the Kloudfuse goroutine total — useful for charting values that span orders of magnitude.
ln(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}))
| Value |
|---|
| 12.86 |
log10
Applies log10 to every sample value of the input vector, preserving all labels. Base-10 logarithm of every sample.
Syntax
log10(<expr>)
Example
Find the order of magnitude of the Kloudfuse goroutine total.
log10(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}))
| Value |
|---|
| 5.585 |
log2
Applies log2 to every sample value of the input vector, preserving all labels. Base-2 logarithm of every sample.
Syntax
log2(<expr>)
Example
Compute log2(1024) — the result is 10.
log2(vector(1024))
| Value |
|---|
| 10 |
round
Applies round to every sample value of the input vector, preserving all labels. Rounds every sample to the nearest multiple.
Syntax
round(<expr> [, <to-nearest>])
Example
Round the Kloudfuse goroutine total to the nearest hundred.
round(sum(go_goroutines{app_kubernetes_io_instance="kfuse"}), 100)
| Value |
|---|
| 385,100 |
sgn
Applies sgn to every sample value of the input vector, preserving all labels. Sign of every sample: -1, 0, or 1.
Syntax
sgn(<expr>)
Example
Reduce the 30-minute goroutine trend to its direction: growing (1), flat (0), or shrinking (-1).
sgn(delta(go_goroutines{app_kubernetes_io_name="query-service"}[30m]))
| Value |
|---|
| -1 |
| 1 |
| 1 |
| -1 |
| -1 |
sqrt
Applies sqrt to every sample value of the input vector, preserving all labels. Square root of every sample.
Syntax
sqrt(<expr>)
Example
Compute the square root of 256 — the result is 16.
sqrt(vector(256))
| Value |
|---|
| 16 |