ceiling
Use ceiling when you want to convert decimal numbers to whole numbers by rounding up. For example, if you have 7.2 requests per second and need to provision whole server instances, ceiling ensures you allocate 8 instances rather than 7.
Usage#
Syntax#
ceiling(number)Parameters#
| Name | Type | Description |
|---|---|---|
number |
real |
The numeric value to round up. |
Returns#
An integer representing the smallest whole number greater than or equal to the input value.
Use case examples#
Round request durations up to whole milliseconds for consistent bucketing.
Query
['sample-http-logs']
| extend duration_bucket = ceiling(req_duration_ms) * 100
| summarize request_count = count() by duration_bucket
| order by duration_bucket ascOutput
| duration_bucket | request_count |
|---|---|
| 100 | 1250 |
| 200 | 3420 |
| 300 | 2180 |
| 400 | 890 |
This query groups requests into 100ms buckets using ceiling to ensure all fractional durations round up to the next bucket boundary.
Calculate the minimum number of seconds to allocate for trace processing.
Query
['otel-demo-traces']
| extend duration_seconds = ceiling(duration / 1s)
| summarize avg_duration_seconds = avg(duration_seconds) by ['service.name']
| order by avg_duration_seconds descOutput
| service.name | avg_duration_seconds |
|---|---|
| checkout | 5 |
| product-catalog | 3 |
| cart | 2 |
| frontend | 1 |
This query rounds span durations up to whole seconds to estimate resource allocation per service.
List of related functions#
- floor: Rounds down to the largest integer less than or equal to the input. Use
ceilingwhen you need to round up instead. - bin: Rounds values down to a multiple of a specified bin size. Use
ceilingfor simple upward rounding to integers. - round: Rounds to the nearest integer or specified precision. Use
ceilingwhen you always need to round up.
Other query languages#
Splunk SPL users
In Splunk SPL, you use the ceil or ceiling function to round up values. APL's ceiling function works the same way.
Splunk example
| eval rounded_up = ceil(request_time)APL equivalent
['sample-http-logs']
| extend rounded_up = ceiling(req_duration_ms)ANSI SQL users
In ANSI SQL, the CEILING or CEIL function performs the same operation. APL's syntax is nearly identical.
SQL example
SELECT CEILING(request_duration) AS rounded_up FROM logsAPL equivalent
['sample-http-logs']
| extend rounded_up = ceiling(req_duration_ms)