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; i.e. <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:logscaleround("field")
and:
logscaleround(field="field")
These examples show basic structure only.
round()
Examples
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
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
round(myvalue)
Rounds the number in myvalue
Event Result set
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
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
format("%.2f", field=value)
Round the field value to two decimal places.
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
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] result{{Result Set}} repo --> 0 0 --> 1 1 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
timechart(function=max(value))
Create a
Time Chart
usingmax()
as the aggregate function for the value field. - flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] result{{Result Set}} repo --> 0 0 --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
| round(_max, how=floor)
Round 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
reolved to their base value which can make the differences between
values easier to distinguish when used on a graph.