formatDuration() Query Function

Format a duration into a human readable string.

Parameters

Name

Type

Required

Default

Description

field

string

Yes

The name of the input field.

as

string

No

The output name of the field to set (defaults to the same as the input field).

from

string

No

Magnitude of the input field. Accepted values: ns, us, ms, s, m, h, d. Defaults to ms.

precision

number

No

Number of units to use in the output. If zero (default), all units are used.

The implied parameter is field.

Examples

Formats a duration into a string. An input event with the field duration with the value 23452553 results in the field duration having the value 6h30m52s553ms.

humio
formatDuration(duration)

Formats a duration into a string with limited precision. An input event with the field duration with the value 23452553 results in the field duration having the value 6h30m52s.

humio
formatDuration(duration, precision=3)