Back to Influxdb

hourSelection() function

content/flux/v0/stdlib/universe/hourselection.md

latest2.3 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/universe/universe.flux#L1043-L1051 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

hourSelection() filters rows by time values in a specified hour range.

Function type signature
js
(
    <-tables: stream[A],
    start: int,
    stop: int,
    ?location: {zone: string, offset: duration},
    ?timeColumn: string,
) => stream[A] where A: Record

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

start

({{< req >}}) First hour of the hour range (inclusive). Hours range from [0-23].

stop

({{< req >}}) Last hour of the hour range (inclusive). Hours range from [0-23].

location

Location used to determine timezone. Default is the location option.

timeColumn

Column that contains the time value. Default is _time.

tables

Input data. Default is piped-forward data (<-).

Examples

Filter by business hours

js
data
    |> hourSelection(start: 9, stop: 17)

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_timetag_value
2022-01-01T05:00:00Zt1-2
2022-01-01T09:00:10Zt110
2022-01-01T11:00:20Zt17
2022-01-01T16:00:30Zt117
2022-01-01T19:00:40Zt115
2022-01-01T20:00:50Zt14

Output data

_timetag_value
2022-01-01T09:00:10Zt110
2022-01-01T11:00:20Zt17
2022-01-01T16:00:30Zt117

{{% /expand %}} {{< /expand-wrapper >}}