Flux 0.133 (#3203)

* fix(flux): mqtt changes (#3191)

* docs: add publish function

* docs: remove message parameter

* docs: add retain parameter description

* docs: apply suggestions from code review

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* added flux 0.133.0 release notes

* added location info for flux-0.133

* updated location param description

* added commas to flux release notes

Co-authored-by: alespour <42931850+alespour@users.noreply.github.com>
pull/3204/head^2
Scott Anderson 2021-10-05 09:21:42 -06:00 committed by GitHub
parent 421bf757f4
commit 494beb2215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 161 additions and 11 deletions

View File

@ -10,6 +10,24 @@ aliases:
- /influxdb/cloud/reference/release-notes/flux/
---
## v0.133.0 [2021-10-04]
### Features
- Expose location functionality to [`window()`](/flux/v0.x/stdlib/universe/window/),
[`aggregateWindow()`](/flux/v0.x/stdlib/universe/aggregatewindow/), and
[`experimental.window()`](/flux/v0.x/stdlib/experimental/window/).
- Add location functionality to the `interval` package.
- Add methods to convert time values to and from local clock time.
- Add [`mqtt.publish()` function](/flux/v0.x/stdlib/experimental/mqtt/publish/).
- Add [`retain` parameter](/flux/v0.x/stdlib/experimental/mqtt/to/#retain) to
[`mqtt.to`](/flux/v0.x/stdlib/experimental/mqtt/to/).
### Bug fixes
- Add `range()` before `window()` to set query time bounds in tests.
- Use a new `Fresher` instance for each package.
---
## v0.132.0 [2021-09-28]
### Features

View File

@ -0,0 +1,100 @@
---
title: mqtt.publish() function
description: >
The `mqtt.publish()` function outputs data to an MQTT broker using MQTT protocol.
menu:
flux_0_x_ref:
name: mqtt.publish
parent: mqtt
weight: 401
introduced: 0.133.0
---
The `mqtt.publish()` function outputs data to an MQTT broker using MQTT protocol.
```js
import "experimental/mqtt"
mqtt.publish(
broker: "tcp://localhost:8883",
topic: "example-topic",
message: "Example message",
qos: 0,
retain: false,
clientid: "flux-mqtt",
username: "username",
password: "password",
timeout: 1s
)
```
## Parameters
### broker {data-type="string"}
The MQTT broker connection string.
### topic {data-type="string"}
The MQTT topic to send data to.
### message {data-type="string"}
The message to send to the MQTT broker.
### qos {data-type="int"}
The [MQTT Quality of Service (QoS)](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103) level.
Values range from `[0-2]`.
Default is `0`.
### retain {data-type="bool"}
The [MQTT retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901042) flag.
Default is `false`.
### clientid {data-type="string"}
The MQTT client ID.
### username {data-type="string"}
The username to send to the MQTT broker.
Username is only required if the broker requires authentication.
If you provide a username, you must provide a [password](#password).
### password {data-type="string"}
The password to send to the MQTT broker.
Password is only required if the broker requires authentication.
If you provide a password, you must provide a [username](#username).
### timeout {data-type="duration"}
The MQTT connection timeout.
Default is `1s`.
## Examples
#### Send a message to an MQTT endpoint
```js
import "experimental/mqtt"
mqtt.publish(
broker: "tcp://localhost:8883",
topic: "alerts",
message: "wake up",
clientid: "alert-watcher",
retain: true
)
```
#### Send a message to an MQTT endpoint using input data
```js
import "experimental/mqtt"
import "influxdata/influxdb/sample"
sample.data(set: "airSensor")
|> range(start: -20m)
|> last()
|> map(fn: (r) => ({
r with
sent: mqtt.publish(
broker: "tcp://localhost:8883",
topic: "air-sensors/last/${r.sensorID}",
message: string(v: r._value),
clientid: "sensor-12a4"
)
}))
```

View File

@ -22,7 +22,6 @@ import "experimental/mqtt"
mqtt.to(
broker: "tcp://localhost:8883",
topic: "example-topic",
message: "Example message",
qos: 0,
clientid: "flux-mqtt",
username: "username",
@ -43,20 +42,15 @@ The MQTT broker connection string.
### topic {data-type="string"}
The MQTT topic to send data to.
### message {data-type="string"}
The message or payload to send to the MQTT broker.
The default payload is an output table.
If there are multiple output tables, it sends each table as a separate MQTT message.
{{% note %}}
When you specify a message, the function sends the message string only (no output table).
{{% /note %}}
### qos {data-type="int"}
The [MQTT Quality of Service (QoS)](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103) level.
Values range from `[0-2]`.
Default is `0`.
### retain {data-type="bool"}
The [MQTT retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901042) flag.
Default is `false`.
### clientid {data-type="string"}
The MQTT client ID.

View File

@ -32,6 +32,7 @@ window(
every: 5m,
period: 5m,
offset: 12h,
location: "UTC",
createEmpty: false
)
```
@ -60,6 +61,13 @@ Offset is the duration by which to shift the window boundaries.
It can be negative, indicating that the offset goes backwards in time.
Defaults to 0, which will align window end boundaries with the `every` duration.
### location {data-type="string"}
Location used to determine timezone.
Default is the [`location` option](/flux/v0.x/stdlib/universe/#location).
_Flux uses the timezone database (commonly referred to as "tz" or "zoneinfo")
provided by the operating system._
### createEmpty {data-type="bool"}
Specifies whether empty tables should be created.
Defaults to `false`.

View File

@ -25,6 +25,7 @@ The `universe` package provides the following options:
```js
option now = () => system.time
option location = "UTC"
```
### now {data-type="function"}
@ -32,5 +33,11 @@ Function option that, by default, returns the current system time.
The value of `now()` is cached at query time, so all instances of `now()` in a
script return the same time value.
### location {data-type="string"}
Location used to determine timezone. Default is `"UTC"`.
Flux uses the timezone information (commonly referred to as "tz" or "zoneinfo")
provided by the operating system.
## Functions
{{< children type="functions" >}}

View File

@ -19,16 +19,18 @@ flux/v0.x/tags: [transformations]
introduced: 0.7.0
---
The `aggregateWindow()` function applies an aggregate or selector function
`aggregateWindow()` applies an aggregate or selector function
(any function with a `column` parameter) to fixed windows of time.
```js
aggregateWindow(
every: 1m,
period: 1m,
fn: mean,
column: "_value",
timeSrc: "_stop",
timeDst: "_time",
location: "UTC",
createEmpty: true
)
```
@ -66,6 +68,12 @@ When aggregating by week (`1w`), weeks are determined using the
all calculated weeks begin on Thursday.
{{% /note %}}
### period {data-type="duration"}
Duration of the window.
Period is the length of each interval.
The period can be negative, indicating the start and stop boundaries are reversed.
Defaults to `every` value.
### fn {data-type="function"}
[Aggregate](/flux/v0.x/function-types/#aggregates)
@ -91,6 +99,13 @@ Defaults to `"_stop"`.
The "time destination" column to which time is copied for the aggregate record.
Defaults to `"_time"`.
### location {data-type="string"}
Location used to determine timezone.
Default is the [`location` option](/flux/v0.x/stdlib/universe/#location).
_Flux uses the timezone database (commonly referred to as "tz" or "zoneinfo")
provided by the operating system._
### createEmpty {data-type="bool"}
For windows without data, create a single-row table for each empty window (using

View File

@ -35,6 +35,7 @@ window(
timeColumn: "_time",
startColumn: "_start",
stopColumn: "_stop",
location: "UTC",
createEmpty: false
)
```
@ -79,6 +80,13 @@ Defaults to `"_start"`.
The column containing the window stop time.
Defaults to `"_stop"`.
### location {data-type="string"}
Location used to determine timezone.
Default is the [`location` option](/flux/v0.x/stdlib/universe/#location).
_Flux uses the timezone database (commonly referred to as "tz" or "zoneinfo")
provided by the operating system._
### createEmpty {data-type="bool"}
Specifies whether empty tables should be created.
Defaults to `false`.