Format a duration into a human readable string.

ParameterTypeRequiredDefaultDescription
asstringfalse The output name of the field to set (defaults to the same as the input field).
fieldstringtrue The name of the input field.
fromstringfalse Magnitude of the input field. Accepted values: ns, us, ms, s, m, h, d. Defaults to ms.
precisionnumberfalse Number of units to use in the output. If zero (default), all units are used.

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)