stateDuration() function

    *Function type: Transformation
    **
    Output data type:* Duration

    As the first point in the given state has no previous point, its state duration will be 0.

    Make sure fn parameter names match each specified parameter. To learn why, see Match parameter names.

    A single argument function that evaluates true or false to identify the state of the record. Records are passed to the function. Those that evaluate to true increment the state duration. Those that evaluate to reset the state duration.

    The name of the column added to each record that contains the state duration.

    *Data type: String*

    *Data type: Duration*

    Examples

    1. from("monitor/autogen")
    2. |> filter(fn: (r) => r._measurement == "http")
    3. fn: (r) => r.http_response_code == "500",
    4. column: "server_error_duration"
    5. )

    Related articles