Flux 0.115 (#2517)
* Flux Alerta package (in the correct branch) (#2498) * Flux Alerta package (#2494) * added flux alerta pkg, closes #2492 * duplicated alerta packages in cloud * Revert "Flux Alerta package (#2494)" (#2497) This reverts commitpull/2522/heade8907fa54a. * Revert "Revert "Flux Alerta package (#2494)" (#2497)" This reverts commit0704845f45. * Flux experimental table package (#2496) * flux table.fill function, closes #2493 * updated table.fill page weight * added import statement and syntax key to table.fill example * minor content change on table.fill * flux 0.115 release notes * added duplicate-oss to table package in cloud
parent
20de2ada9a
commit
8f3dcffb4f
|
|
@ -54,3 +54,9 @@ table {
|
|||
td:nth-child(2) code { margin-left: -2rem; }
|
||||
}
|
||||
}
|
||||
|
||||
p.table-group-key {
|
||||
margin: 1rem 0 -.75rem;
|
||||
font-weight: $medium;
|
||||
font-size: .87rem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
title: Flux Alerta package
|
||||
list_title: Alerta package
|
||||
description: >
|
||||
The Flux Alerta package provides functions that send alerts to
|
||||
[Alerta](https://alerta.io/).
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: Alerta
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
influxdb/cloud/tags: [functions, alerta, package]
|
||||
cascade:
|
||||
append:
|
||||
block: note
|
||||
content: |
|
||||
#### Package author and maintainer
|
||||
**Github:** [@alespour](https://github.com/alespour), [@bonitoo-io](https://github.com/bonitoo-io)
|
||||
**InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack)
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
title: alerta.alert() function
|
||||
description: >
|
||||
The `alerta.alert()` function sends an alert to Alerta.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: alerta.alert
|
||||
parent: Alerta
|
||||
weight: 202
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
title: alerta.endpoint() function
|
||||
description: >
|
||||
The `alerta.endpoint()` function sends alerts to Alerta using data from input rows.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: alerta.endpoint
|
||||
parent: Alerta
|
||||
weight: 202
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
title: Flux Experimental table package
|
||||
list_title: Table package
|
||||
description: >
|
||||
The Flux experimental table package provides tools working with Flux tables.
|
||||
Import the `experimental/table` package.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: Table
|
||||
identifier: table-exp
|
||||
parent: Experimental
|
||||
weight: 301
|
||||
influxdb/cloud/tags: [functions, table, package]
|
||||
cascade:
|
||||
introduced: 0.115.0
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: table.fill() function
|
||||
description: >
|
||||
The `table.fill()` function adds a single row to empty tables in a stream of tables.
|
||||
Columns in the group key are filled with the column value defined in the group key.
|
||||
Columns not in the group key are filled with a null value.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: table.fill
|
||||
parent: table-exp
|
||||
weight: 401
|
||||
influxdb/cloud/tags: [functions, table, fill, package]
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: Flux Alerta package
|
||||
list_title: Alerta package
|
||||
description: >
|
||||
The Flux Alerta package provides functions that send alerts to
|
||||
[Alerta](https://alerta.io/).
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: Alerta
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
influxdb/v2.0/tags: [functions, alerta, package]
|
||||
cascade:
|
||||
append:
|
||||
block: note
|
||||
content: |
|
||||
#### Package author and maintainer
|
||||
**Github:** [@alespour](https://github.com/alespour), [@bonitoo-io](https://github.com/bonitoo-io)
|
||||
**InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack)
|
||||
---
|
||||
|
||||
The Flux Alerta package provides functions that send alerts to
|
||||
[Alerta](https://alerta.io/).
|
||||
Import the `contrib/bonitoo-io/alerta` package:
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/alerta"
|
||||
```
|
||||
|
||||
## Functions
|
||||
{{< children type="functions" show="pages" >}}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
---
|
||||
title: alerta.alert() function
|
||||
description: >
|
||||
The `alerta.alert()` function sends an alert to Alerta.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: alerta.alert
|
||||
parent: Alerta
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `alerta.alert()` function sends an alert to [Alerta](https://www.alerta.io/).
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/alerta"
|
||||
|
||||
alerta.alert(
|
||||
url: "https://alerta.io:8080/alert",
|
||||
apiKey: "0Xx00xxXx00Xxx0x0X",
|
||||
resource: "example-resource",
|
||||
event: "Example event",
|
||||
environment: "",
|
||||
severity: "critical",
|
||||
service: [],
|
||||
group: "",
|
||||
value: "",
|
||||
text: "",
|
||||
tags: [],
|
||||
attributes: {},
|
||||
origin: "InfluxDB",
|
||||
type: "",
|
||||
timestamp: now(),
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
({{< req >}})
|
||||
Alerta URL.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### apiKey
|
||||
({{< req >}})
|
||||
Alerta API key.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### resource
|
||||
({{< req >}})
|
||||
Resource associated with the alert.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### event
|
||||
({{< req >}})
|
||||
Event name.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### environment
|
||||
Alert environment.
|
||||
Default is `""`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
**Valid values:**
|
||||
|
||||
- `""`
|
||||
- `"Production"`
|
||||
- `"Development"`
|
||||
|
||||
### severity
|
||||
({{< req >}})
|
||||
Event severity.
|
||||
See [Alerta severities](https://docs.alerta.io/en/latest/api/alert.html#alert-severities).
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### service
|
||||
List of affected services.
|
||||
Default is `[]`.
|
||||
|
||||
_**Data type:** Array of strings_
|
||||
|
||||
### group
|
||||
Alerta event group.
|
||||
Default is `""`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### value
|
||||
Event value.
|
||||
Default is `""`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### text
|
||||
Alert text description.
|
||||
Default is `""`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### tags
|
||||
List of event tags.
|
||||
Default is `[]`.
|
||||
|
||||
_**Data type:** Array of strings_
|
||||
|
||||
### attributes
|
||||
({{< req >}})
|
||||
Alert attributes.
|
||||
|
||||
_**Data type:** Record_
|
||||
|
||||
### origin
|
||||
Alert origin.
|
||||
Default is `"InfluxDB"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### type
|
||||
Event type.
|
||||
Default is `""`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### timestamp
|
||||
time alert was generated.
|
||||
Default is `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send the last reported value and status to Alerta
|
||||
```js
|
||||
import "contrib/bonitoo-io/alerta"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
apiKey = secrets.get(key: "ALERTA_API_KEY")
|
||||
|
||||
lastReported =
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "example-measurement" and
|
||||
r._field == "level"
|
||||
)
|
||||
|> last()
|
||||
|> findRecord(fn: (key) => true, idx: 0)
|
||||
|
||||
severity = if lastReported._value > 50 then "warning" else "ok"
|
||||
|
||||
alerta.alert(
|
||||
url: "https://alerta.io:8080/alert",
|
||||
apiKey: apiKey,
|
||||
resource: "example-resource",
|
||||
event: "Example event",
|
||||
environment: "Production",
|
||||
severity: severity,
|
||||
service: ["example-service"],
|
||||
group: "example-group",
|
||||
value: string(v: lastReported._value),
|
||||
text: "Service is ${severity}. The last reported value was ${string(v: lastReported._value)}.",
|
||||
tags: ["ex1", "ex2"],
|
||||
attributes: {},
|
||||
origin: "InfluxDB",
|
||||
type: "exampleAlertType",
|
||||
timestamp: now(),
|
||||
)
|
||||
```
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
---
|
||||
title: alerta.endpoint() function
|
||||
description: >
|
||||
The `alerta.endpoint()` function sends alerts to Alerta using data from input rows.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: alerta.endpoint
|
||||
parent: Alerta
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `alerta.endpoint()` function sends alerts to [Alerta](https://alerta.io/)
|
||||
using data from input rows.
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/alerta"
|
||||
|
||||
alerta.endpoint(
|
||||
url: "https://alerta.io:8080/alert,
|
||||
apiKey: "0Xx00xxXx00Xxx0x0X",
|
||||
environment: "",
|
||||
origin: "InfluxDB"
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
({{< req >}})
|
||||
Alerta URL.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### apiKey
|
||||
({{< req >}})
|
||||
Alerta API key.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### environment
|
||||
Alert environment.
|
||||
Default is `""`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
**Valid values:**
|
||||
|
||||
- `""`
|
||||
- `"Production"`
|
||||
- `"Development"`
|
||||
|
||||
### origin
|
||||
Alert origin.
|
||||
Default is `"InfluxDB"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Usage
|
||||
`alerta.endpoint` is a factory function that outputs another function.
|
||||
The output function requires a `mapFn` parameter.
|
||||
|
||||
### mapFn
|
||||
A function that builds the object used to generate the POST request.
|
||||
Requires an `r` parameter.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
`mapFn` accepts a table row (`r`) and returns an object that must include the
|
||||
following fields:
|
||||
|
||||
- `resource`
|
||||
- `event`
|
||||
- `severity`
|
||||
- `service`
|
||||
- `group`
|
||||
- `value`
|
||||
- `text`
|
||||
- `tags`
|
||||
- `attributes`
|
||||
- `type`
|
||||
- `timestamp`
|
||||
|
||||
_For more information, see [`alerta.alert()` parameters](/influxdb/v2.0/reference/flux/stdlib/contrib/alerta/alert/#parameters)._
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send critical alerts to Alerta
|
||||
```js
|
||||
import "contrib/bonitoo-io/alerta"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
apiKey = secrets.get(key: "ALERTA_API_KEY")
|
||||
endpoint = alerta.endpoint(
|
||||
url: "https://alerta.io:8080/alert",
|
||||
apiKey: apiKey,
|
||||
environment: "Production",
|
||||
origin: "InfluxDB"
|
||||
)
|
||||
|
||||
crit_events = from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
|
||||
|
||||
crit_events
|
||||
|> endpoint(mapFn: (r) => {
|
||||
return { r with
|
||||
resource: "example-resource",
|
||||
event: "example-event",
|
||||
severity: "critical",
|
||||
service: r.service,
|
||||
group: "example-group",
|
||||
value: r.status,
|
||||
text: "Status is critical.",
|
||||
tags: ["ex1", "ex2"],
|
||||
attributes: {},
|
||||
type: "exampleAlertType",
|
||||
timestamp: now(),
|
||||
}
|
||||
})()
|
||||
```
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: Flux Experimental table package
|
||||
list_title: Table package
|
||||
description: >
|
||||
The Flux experimental table package provides tools working with Flux tables.
|
||||
Import the `experimental/table` package.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: Table
|
||||
identifier: table-exp
|
||||
parent: Experimental
|
||||
weight: 301
|
||||
influxdb/v2.0/tags: [functions, table, package]
|
||||
cascade:
|
||||
introduced: 0.115.0
|
||||
---
|
||||
|
||||
The Flux experimental table package provides tools working with Flux tables.
|
||||
Import the `experimental/table` package:
|
||||
|
||||
```js
|
||||
import "experimental/table"
|
||||
```
|
||||
|
||||
{{< children type="functions" show="pages" >}}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
title: table.fill() function
|
||||
description: >
|
||||
The `table.fill()` function adds a single row to empty tables in a stream of tables.
|
||||
Columns in the group key are filled with the column value defined in the group key.
|
||||
Columns not in the group key are filled with a null value.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: table.fill
|
||||
parent: table-exp
|
||||
weight: 401
|
||||
influxdb/v2.0/tags: [functions, table, fill, package]
|
||||
---
|
||||
|
||||
The `table.fill()` function adds a single row to empty tables in a stream of tables.
|
||||
Columns that are in the group key are filled with the column value defined in the group key.
|
||||
Columns not in the group key are filled with a null value.
|
||||
|
||||
```js
|
||||
import "experimental/table"
|
||||
|
||||
table.fill()
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
##### Query
|
||||
```js
|
||||
import "experimental/table"
|
||||
|
||||
data
|
||||
|> table.fill()
|
||||
```
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
##### Input data
|
||||
|
||||
<p class="table-group-key">Group key = [host: "host1", _field: "f1"]</p>
|
||||
|
||||
| host | _field | time | _value |
|
||||
| :---- | :----- | :--- | -----: |
|
||||
| host1 | f1 | 0001 | 2.8 |
|
||||
| host1 | f1 | 0002 | 3.2 |
|
||||
| host1 | f1 | 0003 | 3.3 |
|
||||
|
||||
<p class="table-group-key">Group key = [host: "host2", _field: "f1"]</p>
|
||||
|
||||
| host | _field | time | _value |
|
||||
| :--- | :----- | :--- | -----: |
|
||||
|
||||
<p class="table-group-key">Group key = [host: "host3", _field: "f1"]</p>
|
||||
|
||||
| host | _field | time | _value |
|
||||
| :---- | :----- | :--- | -----: |
|
||||
| host3 | f1 | 0001 | 1.4 |
|
||||
| host3 | f1 | 0002 | 1.5 |
|
||||
| host3 | f1 | 0003 | 2.7 |
|
||||
{{% /flex-content %}}
|
||||
{{% flex-content %}}
|
||||
##### Output data
|
||||
|
||||
<p class="table-group-key">Group key = [host: "host1", _field: "f1"]</p>
|
||||
|
||||
| host | _field | time | _value |
|
||||
| :---- | :----- | :--- | -----: |
|
||||
| host1 | f1 | 0001 | 2.8 |
|
||||
| host1 | f1 | 0002 | 3.2 |
|
||||
| host1 | f1 | 0003 | 3.3 |
|
||||
|
||||
<p class="table-group-key">Group key = [host: "host2", _field: "f1"]</p>
|
||||
|
||||
| host | _field | time | _value |
|
||||
| :---- | :----- | :--- | -----: |
|
||||
| host2 | f1 | | |
|
||||
|
||||
<p class="table-group-key">Group key = [host: "host3", _field: "f1"]</p>
|
||||
|
||||
| host | _field | time | _value |
|
||||
| :---- | :----- | :--- | -----: |
|
||||
| host3 | f1 | 0001 | 1.4 |
|
||||
| host3 | f1 | 0002 | 1.5 |
|
||||
| host3 | f1 | 0003 | 2.7 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
|
|
@ -8,6 +8,23 @@ menu:
|
|||
name: Flux
|
||||
---
|
||||
|
||||
## v0.115.0 [2021-05-11]
|
||||
|
||||
### Features
|
||||
- Add [Alerta notifications support](/influxdb/v2.0/reference/flux/stdlib/contrib/alerta/).
|
||||
- Add [`table.fill()` function](/influxdb/v2.0/reference/flux/stdlib/experimental/table/fill/)
|
||||
to fill empty tables with a single row.
|
||||
- Add string formatting to `dict` type.
|
||||
|
||||
### Bug fixes
|
||||
- Refactor semantic printing of types.
|
||||
- Do not remove escape characters when auto-formatting.
|
||||
- Add `0.0.0.0` to URL validator.
|
||||
- Add new display API for values.
|
||||
- Auto-format Flux files in `stdlib/testing`.
|
||||
|
||||
---
|
||||
|
||||
## v0.114.1 [2021-05-04]
|
||||
|
||||
### Bug fixes
|
||||
|
|
|
|||
Loading…
Reference in New Issue