Rounds a numeric input field to the nearest integer, with an optional method to set the rounding type.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
as | string | optional[a] | Same name as input field | The output name of the field to round. |
field [b] | string | required | The names of the field to round. | |
how | string | optional[a] | round | Method used to round the number. |
Valid Values | ||||
ceil | Round up to the nearest whole number | |||
floor | Round down to the nearest whole number | |||
round | Standard rules; for example, <0.5 rounds down, >0.5 rounds up | |||
[a] Optional parameters use their default value unless explicitly set. |
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
field
can be omitted; the following forms of this function are equivalent:logscale Syntaxround("value")
and:
logscale Syntaxround(field="value")
These examples show basic structure only.
round()
Examples
Click
next to an example below to get the full details.Basic Rounding
Query
round(myvalue)
Introduction
Round a number to the nearest integer using standard math rules. Numbers greater than 0.5 are rounded up, numbers lower than 0.5 are rounded down.
Step-by-Step
Starting with the source repository events.
- logscale
round(myvalue)
Rounds the number in myvalue
Event Result set.
Rounding Within a Timechart
Query
timechart(function=max(value))
| round(_max, how=floor)
Introduction
Round a field and display using a Time
chart
.
Step-by-Step
Starting with the source repository events.
- logscale
timechart(function=max(value))
Creates a
Time Chart
usingmax()
as the aggregate function for the value field. - logscale
| round(_max, how=floor)
Rounds the implied field from the aggregate
max()
using thefloor
option to round down the value. Event Result set.
Summary and Results
Using the floor
parameter to a function always rounds down a number. This is
useful when displaying information in a time chart as all numbers
resolved to their base value which can make the differences
between values easier to distinguish when used on a graph.
Rounding to n Decimal Places
Query
format("%.2f", field=value)
Introduction
To round a number to a specific number of decimal points, use
format()
rather than
round()
Step-by-Step
Starting with the source repository events.
- logscale
format("%.2f", field=value)
Rounds the field value to two decimal places.
Event Result set.