Rounds a numeric input field to the nearest integer, with an optional method to set the rounding type.

ParameterTypeRequiredDefault ValueDescription
asstringoptional[a]Same name as input field The output name of the field to round.
field[b]stringrequired  The names of the field to round.
howstringoptional[a]round Method used to round the number.
   Valid Values
   ceilRound up to the nearest whole number
   floorRound down to the nearest whole number
   roundStandard rules; for example, <0.5 rounds down, >0.5 rounds up

[a] Optional parameters use their default value unless explicitly set.

[b] The parameter name field can be omitted.

Hide omitted argument names for this function

Show omitted argument names for this function

round() Examples

Click + next to an example below to get the full details.

Basic Rounding

Query
logscale
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
  1. Starting with the source repository events.

  2. logscale
    round(myvalue)

    Rounds the number in myvalue

  3. Event Result set.

Summary and Results

The round() rounds a number to the nearest integer. To format a number, or round to a specific decimal accuracy, use format().

Rounding Within a Timechart

Query
logscale
timechart(function=max(value))
| round(_max, how=floor)
Introduction

Round a field and display using a Time chart.

Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    timechart(function=max(value))

    Creates a Time Chart using max() as the aggregate function for the value field.

  3. logscale
    | round(_max, how=floor)

    Rounds the implied field from the aggregate max() using the floor option to round down the value.

  4. 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
logscale
format("%.2f", field=value)
Introduction

To round a number to a specific number of decimal points, use format() rather than round()

Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    format("%.2f", field=value)

    Rounds the field value to two decimal places.

  3. Event Result set.

Summary and Results

When using format(), rounding is performed using standard math rules. The format() rounds a number to a specific decimal accuracy. To round a number to the nearest decimal, use round().