SlideShare uma empresa Scribd logo
1 de 84
Baixar para ler offline
Scott Anderson
Sr. Technical Writer & Tech Lead
September 2021
Introduction to Flux &
Functional Data Scripting
© 2021 InfluxData. All rights reserved.
2
What is Flux?
A functional data scripting
language designed to query,
process, and act on data.
© 2021 InfluxData. All rights reserved.
3
Design Goals
– Turing-complete
– Useable
– Readable
– Flexible
– Extensible
– Testable
– Contributable
– Shareable
© 2021 InfluxData. All rights reserved.
4
How does
it work?
© 2021 InfluxData. All rights reserved.
5 © 2021 InfluxData. All rights reserved.
5
© 2021 InfluxData. All rights reserved.
6 © 2021 InfluxData. All rights reserved.
6
© 2021 InfluxData. All rights reserved.
7 © 2021 InfluxData. All rights reserved.
7
© 2021 InfluxData. All rights reserved.
8 © 2021 InfluxData. All rights reserved.
8
© 2021 InfluxData. All rights reserved.
9 © 2021 InfluxData. All rights reserved.
9
© 2021 InfluxData. All rights reserved.
10 © 2021 InfluxData. All rights reserved.
10
© 2021 InfluxData. All rights reserved.
11 © 2021 InfluxData. All rights reserved.
11
from(bucket: "system-data")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used_percent"
)
|> aggregateWindow(every: 5m, fn: mean)
© 2021 InfluxData. All rights reserved.
12
Data
Structure
© 2021 InfluxData. All rights reserved.
13 © 2021 InfluxData. All rights reserved.
13
© 2021 InfluxData. All rights reserved.
14 © 2021 InfluxData. All rights reserved.
14
© 2021 InfluxData. All rights reserved.
15 © 2021 InfluxData. All rights reserved.
15
Stream of tables
© 2021 InfluxData. All rights reserved.
16
Table
© 2021 InfluxData. All rights reserved.
17
version userID sessionID _field _value
Table
© 2021 InfluxData. All rights reserved.
18
version userID sessionID _field _value
v1 ex123 ex456 example 1.2
v1 ex123 ex456 example 2.2
v1 ex123 ex456 example 2.3
v2 ex123 ex456 example 1.9
v2 ex123 ex456 example 2.5
v2 ex123 ex456 example 3.1
Table
© 2021 InfluxData. All rights reserved.
19
version userID sessionID _field _value
v1 ex123 ex456 example 1.2
v1 ex123 ex456 example 2.2
v1 ex123 ex456 example 2.3
v2 ex123 ex456 example 1.9
v2 ex123 ex456 example 2.5
v2 ex123 ex456 example 3.1
Table
Group key: [ ]
© 2021 InfluxData. All rights reserved.
20
version userID sessionID _field _value
v1 ex123 ex456 example 1.2
v1 ex123 ex456 example 2.2
v1 ex123 ex456 example 2.3
Tables
Group key: ["version", "userID" ]
version userID sessionID _field _value
v2 ex123 ex456 example 1.9
v2 ex123 ex456 example 2.5
v2 ex123 ex456 example 3.1
© 2021 InfluxData. All rights reserved.
21
version userID sessionID _field _value
v1 ex123 ex456 example 1.2
v1 ex123 ex456 example 2.2
v1 ex123 ex456 example 2.3
Tables
Group key: ["version", "userID" ]
version userID sessionID _field _value
v2 ex123 ex456 example 1.9
v2 ex123 ex456 example 2.5
v2 ex123 ex456 example 3.1
© 2021 InfluxData. All rights reserved.
22 © 2021 InfluxData. All rights reserved.
22
sql.from(
driverName: "mysql",
dataSourceName: "${username}:${password}@tcp(localhost:3306)/db",
query:"SELECT CustomerName,City FROM Customers;"
)
CustomerName City
John Doe New York
Jane Seymour London
Rufus Peck San Francisco
Group key: [ ]
© 2021 InfluxData. All rights reserved.
23 © 2021 InfluxData. All rights reserved.
23
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "m1" and r.field == "f1")
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z m1 host1 f1 1.2
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z m1 host1 f1 2.5
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z m1 host1 f1 2.2
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z m1 host2 f1 1.2
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z m1 host2 f1 2.5
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z m1 host2 f1 2.2
Group key: ["_start", "_stop", "_measurement", "host", "_field"]
© 2021 InfluxData. All rights reserved.
24
Flux
Syntax
© 2021 InfluxData. All rights reserved.
25 © 2021 InfluxData. All rights reserved.
25
Pipe-forward
|>
© 2021 InfluxData. All rights reserved.
26 © 2021 InfluxData. All rights reserved.
26
Basic data types
string "example string"
bool true
float 1.20
int 123456789
uint 123456789
duration 1h
time 2019-12-01T00:00:00Z
bytes [104 101 108 108 111]
© 2021 InfluxData. All rights reserved.
27 © 2021 InfluxData. All rights reserved.
27
Composite data types
record {key1: "value1", key2: 2.0}
array [12, 34, 56]
dict [1: "foo", 2: "bar"]
function f = (x) => x
© 2021 InfluxData. All rights reserved.
28 © 2021 InfluxData. All rights reserved.
28
Variable declarations
varName = varValue
foo = "bar"
bazRecord = {this: 1, that: 8}
data = from(...)
© 2021 InfluxData. All rights reserved.
29 © 2021 InfluxData. All rights reserved.
29
Reference composite types
r = {key1: "value1", key2: 2.0}
Dot notation
r.key1
Returns "value1"
Bracket notation
r["key1"]
Returns "value1"
© 2021 InfluxData. All rights reserved.
30 © 2021 InfluxData. All rights reserved.
30
Reference composite types
arr = [12, 34, 56]
Bracket notation
arr[0]
Returns 12
© 2021 InfluxData. All rights reserved.
31 © 2021 InfluxData. All rights reserved.
31
Reference composite types
dictEx = [1: "foo", 2: "bar"]
Function reference
dict.get(dict: dictEx, key: 1, default: "baz")
Returns "foo"
© 2021 InfluxData. All rights reserved.
32 © 2021 InfluxData. All rights reserved.
32
Reference composite types
dictEx = [1: "foo", 2: "bar"]
Function reference
dict.get(dict: dictEx, key: 3, default: "baz")
Returns "baz"
© 2021 InfluxData. All rights reserved.
33 © 2021 InfluxData. All rights reserved.
33
Reference composite types
r = {key1: "value1", key2: 2.0}
key = "key1"
r.key Returns an error
r["key"] Returns an error
r["${key}"] Returns an error
r = ["key1": "value1", "key2": "2.0"]
key = "key1"
dict.get(
dict: r,
key: key,
default: ""
) Returns "value1"
© 2021 InfluxData. All rights reserved.
34 © 2021 InfluxData. All rights reserved.
34
Functions
f = (x, y) => x / y
f(x: 12, y: 2)
Returns 6
© 2021 InfluxData. All rights reserved.
35 © 2021 InfluxData. All rights reserved.
35
Function types
Static
f = (x, y=2) => x / y
Transformation
f = (t=<-) => t
Predicate
(r) => r.key1 == "foo"
© 2021 InfluxData. All rights reserved.
36 © 2021 InfluxData. All rights reserved.
36
Predicate functions
(r) => 1.0 == 1.0
Parameter(s) Predicate Expression
© 2021 InfluxData. All rights reserved.
37 © 2021 InfluxData. All rights reserved.
37
Predicate functions
(r) => true
© 2021 InfluxData. All rights reserved.
38 © 2021 InfluxData. All rights reserved.
38
Predicate functions
(r) => 1.0 != 1.0
© 2021 InfluxData. All rights reserved.
39 © 2021 InfluxData. All rights reserved.
39
Predicate functions
(r) => false
© 2021 InfluxData. All rights reserved.
40 © 2021 InfluxData. All rights reserved.
40
{
Predicate functions
(r) => 1.0 > 1.0
== != < > <= >= =~ !~
© 2021 InfluxData. All rights reserved.
41 © 2021 InfluxData. All rights reserved.
41
Predicate functions
(r) => 1.0 == 1.0 and "foo" != "bar"
© 2021 InfluxData. All rights reserved.
42 © 2021 InfluxData. All rights reserved.
42
Predicate functions
(r) => true and true
© 2021 InfluxData. All rights reserved.
43 © 2021 InfluxData. All rights reserved.
43
Predicate functions
(r) => true
© 2021 InfluxData. All rights reserved.
44 © 2021 InfluxData. All rights reserved.
44
Predicate functions
(r) => 1.0 > 1.0 and "foo" != "bar"
© 2021 InfluxData. All rights reserved.
45 © 2021 InfluxData. All rights reserved.
45
Predicate functions
(r) => false and true
© 2021 InfluxData. All rights reserved.
46 © 2021 InfluxData. All rights reserved.
46
Predicate functions
(r) => false
© 2021 InfluxData. All rights reserved.
47 © 2021 InfluxData. All rights reserved.
47
Predicate functions
(r) => 1.0 > 1.0 or "foo" != "bar"
© 2021 InfluxData. All rights reserved.
48 © 2021 InfluxData. All rights reserved.
48
Predicate functions
(r) => true
© 2021 InfluxData. All rights reserved.
49 © 2021 InfluxData. All rights reserved.
49
Predicate functions
(r) =>
1.0 == 1.0 and
("foo" == "bar" or "baz" != "quz")
© 2021 InfluxData. All rights reserved.
50 © 2021 InfluxData. All rights reserved.
50
Predicate functions
r = {fname: "John", lname: "Doe", age: 42}
(r) => r.fname == "John" and r.age > 40
© 2021 InfluxData. All rights reserved.
51 © 2021 InfluxData. All rights reserved.
51
Predicate functions
r = {fname: "Mike", lname: "Smith", age: 29}
(r) => r.fname == "John" and r.age > 40
© 2021 InfluxData. All rights reserved.
52
Basic
Query
© 2021 InfluxData. All rights reserved.
53 © 2021 InfluxData. All rights reserved.
53
Basic Query
from(bucket: "system-data")
Source
© 2021 InfluxData. All rights reserved.
54 © 2021 InfluxData. All rights reserved.
54
Basic Query
sql.from(
driverName: "postgres",
dataSourceName: "...",
query: "..."
)
Source
© 2021 InfluxData. All rights reserved.
55 © 2021 InfluxData. All rights reserved.
55
Basic Query
csv.from(csv: "...")
Source
© 2021 InfluxData. All rights reserved.
56 © 2021 InfluxData. All rights reserved.
56
Basic Query
from(bucket: "system-data")
Source
© 2021 InfluxData. All rights reserved.
57 © 2021 InfluxData. All rights reserved.
57
Basic Query
from(bucket: "system-data")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used_percent")
Source
Filter
© 2021 InfluxData. All rights reserved.
58 © 2021 InfluxData. All rights reserved.
58
Basic Query
from(bucket: "system-data")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used_percent")
|> group(columns: ["host"])
Source
Filter
Shape
© 2021 InfluxData. All rights reserved.
59 © 2021 InfluxData. All rights reserved.
59
Basic Query
from(bucket: "system-data")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used_percent")
|> group(columns: ["host"])
|> mean()
Source
Filter
Shape
Process
© 2021 InfluxData. All rights reserved.
60 © 2021 InfluxData. All rights reserved.
60
Basic Query
from(bucket: "system-data")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used_percent")
|> group(columns: ["host"])
|> mean()
Source
Filter
Shape
Process
© 2021 InfluxData. All rights reserved.
61 © 2021 InfluxData. All rights reserved.
61
Process Data
data = from(bucket: "system-data")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used_percent"
)
© 2021 InfluxData. All rights reserved.
62 © 2021 InfluxData. All rights reserved.
62
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 62.1
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 63.8
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 44.0
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7
Process Data
© 2021 InfluxData. All rights reserved.
63 © 2021 InfluxData. All rights reserved.
63
Process Data
data
|> map(fn: (r) => ({_time: r._time, _value: r._value}))
© 2021 InfluxData. All rights reserved.
64 © 2021 InfluxData. All rights reserved.
64
_time _value
2021-01-01T00:09:00Z 62.1
2021-01-01T00:18:00Z 44.0
2021-01-01T00:24:00Z 52.4
2021-01-01T00:28:00Z 63.8
2021-01-01T00:39:00Z 65.4
2021-01-01T00:42:00Z 50.7
Process Data
© 2021 InfluxData. All rights reserved.
65 © 2021 InfluxData. All rights reserved.
65
Process Data
data
|> map(fn: (r) => ({r with _value: r._value * 0.01}))
© 2021 InfluxData. All rights reserved.
66 © 2021 InfluxData. All rights reserved.
66
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 0.621
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 0.638
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 0.654
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 0.44
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 0.524
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 0.507
Process Data
© 2021 InfluxData. All rights reserved.
67 © 2021 InfluxData. All rights reserved.
67
Process Data
data
|> map(fn: (r) => ({
r with
state: if r._value > 65.0 then "high" else "ok"
}))
© 2021 InfluxData. All rights reserved.
68 © 2021 InfluxData. All rights reserved.
68
_start _stop _time _measurement host _field _value state
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 62.1 ok
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 63.8 ok
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4 high
_start _stop _time _measurement host _field _value state
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 44.0 ok
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4 ok
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7 ok
Process Data
© 2021 InfluxData. All rights reserved.
69 © 2021 InfluxData. All rights reserved.
69
Process Data
data |> mean()
© 2021 InfluxData. All rights reserved.
70
|> mean()
© 2021 InfluxData. All rights reserved.
71 © 2021 InfluxData. All rights reserved.
71
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 62.1
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 63.8
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 44.0
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7
Process Data
© 2021 InfluxData. All rights reserved.
72 © 2021 InfluxData. All rights reserved.
72
_start _stop _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host1 used_percent 63.8
_start _stop _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host2 used_percent 49.0
Process Data
© 2021 InfluxData. All rights reserved.
73 © 2021 InfluxData. All rights reserved.
73
Process Data
data |> sum()
© 2021 InfluxData. All rights reserved.
74 © 2021 InfluxData. All rights reserved.
74
_start _stop _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host1 used_percent 191.3
_start _stop _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host2 used_percent 147.1
Process Data
© 2021 InfluxData. All rights reserved.
75 © 2021 InfluxData. All rights reserved.
75
Process Data
data |> max()
© 2021 InfluxData. All rights reserved.
76 © 2021 InfluxData. All rights reserved.
76
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4
Process Data
© 2021 InfluxData. All rights reserved.
77 © 2021 InfluxData. All rights reserved.
77
Process Data
data |> last()
© 2021 InfluxData. All rights reserved.
78 © 2021 InfluxData. All rights reserved.
78
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4
_start _stop _time _measurement host _field _value
2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7
Process Data
© 2021 InfluxData. All rights reserved.
79
Flux in
Practice
© 2021 InfluxData. All rights reserved.
80 © 2021 InfluxData. All rights reserved.
80
from(bucket: "market-summary")
|> range(start: -6mo)
|> filter(fn: (r) =>
r._measurement == "stockPrices" and
r.symbol == "GME"
)
|> holtWinters(n: 24, seasonality: 12, interval: 1w)
© 2021 InfluxData. All rights reserved.
81 © 2021 InfluxData. All rights reserved.
81
heatIndex = (t, h) => //...
from(bucket: "sensor-data")
|> range(start: -1d)
|> filter(fn: (r) => r._measurement == "sensors")
|> filter(fn: (r) => r._field == "temp" or r._field == "hum")
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({ r with heatIndex: heatIndex(t: r.temp, h: r.hum) }))
© 2021 InfluxData. All rights reserved.
82 © 2021 InfluxData. All rights reserved.
82
import "sql"
sensorInfo = sql.from(
driverName: "postgres",
dataSourceName: "postgresql://localhost?sslmode=disable",
query: "SELECT * FROM sensors"
)
sensorMetrics = from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "airSensors")
join(tables: {metric: sensorMetrics, info: sensorInfo}, on: ["sensor_id"])
|> group(columns: ["sensor_id", "lastInspected"]),
|> aggregateWindow(
every: 5m,
fn: (tables=<-, column="error") => tables |> count(column: column)
)
Thank You
October 11-12, 2021
Hands-On Flux Training
October 26-27, 2021
Virtual Experience
We look forward to bringing together our
community of developers to learn, interact and
share tips and use cases.
https://www.influxdays.com/influxdays-north-america-2021-virtual-experience/

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

How an Open Marine Standard, InfluxDB and Grafana Are Used to Improve Boating...
How an Open Marine Standard, InfluxDB and Grafana Are Used to Improve Boating...How an Open Marine Standard, InfluxDB and Grafana Are Used to Improve Boating...
How an Open Marine Standard, InfluxDB and Grafana Are Used to Improve Boating...
 
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
 
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
 
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
 
Catalogs - Turning a Set of Parquet Files into a Data Set
Catalogs - Turning a Set of Parquet Files into a Data SetCatalogs - Turning a Set of Parquet Files into a Data Set
Catalogs - Turning a Set of Parquet Files into a Data Set
 
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOxInfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
 
Write your own telegraf plugin
Write your own telegraf pluginWrite your own telegraf plugin
Write your own telegraf plugin
 
Inside the InfluxDB storage engine
Inside the InfluxDB storage engineInside the InfluxDB storage engine
Inside the InfluxDB storage engine
 
Getting Ready to Move to InfluxDB 2.0 | Tim Hall | InfluxData
Getting Ready to Move to InfluxDB 2.0 | Tim Hall | InfluxData Getting Ready to Move to InfluxDB 2.0 | Tim Hall | InfluxData
Getting Ready to Move to InfluxDB 2.0 | Tim Hall | InfluxData
 
How to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah CrowleyHow to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah Crowley
 
How to Use Telegraf and Its Plugin Ecosystem
How to Use Telegraf and Its Plugin EcosystemHow to Use Telegraf and Its Plugin Ecosystem
How to Use Telegraf and Its Plugin Ecosystem
 
Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...
Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...
Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...
 
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
 
Vasilis Papavasiliou [Mist.io] | Integrating Telegraf, InfluxDB and Mist to M...
Vasilis Papavasiliou [Mist.io] | Integrating Telegraf, InfluxDB and Mist to M...Vasilis Papavasiliou [Mist.io] | Integrating Telegraf, InfluxDB and Mist to M...
Vasilis Papavasiliou [Mist.io] | Integrating Telegraf, InfluxDB and Mist to M...
 
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxDataInfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
 
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
 
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and TelegrafObtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
 
How to Store and Visualize CAN Bus Telematic Data with InfluxDB Cloud and Gra...
How to Store and Visualize CAN Bus Telematic Data with InfluxDB Cloud and Gra...How to Store and Visualize CAN Bus Telematic Data with InfluxDB Cloud and Gra...
How to Store and Visualize CAN Bus Telematic Data with InfluxDB Cloud and Gra...
 
Tim Hall and Ryan Betts [InfluxData] | InfluxDB Roadmap and Engineering Updat...
Tim Hall and Ryan Betts [InfluxData] | InfluxDB Roadmap and Engineering Updat...Tim Hall and Ryan Betts [InfluxData] | InfluxDB Roadmap and Engineering Updat...
Tim Hall and Ryan Betts [InfluxData] | InfluxDB Roadmap and Engineering Updat...
 
Keep Calm and Distributed Tracing
Keep Calm and Distributed TracingKeep Calm and Distributed Tracing
Keep Calm and Distributed Tracing
 

Semelhante a Introduction to Flux and Functional Data Scripting

Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software security
DefconRussia
 

Semelhante a Introduction to Flux and Functional Data Scripting (20)

Taming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using Telegraf
 
2021 10-13 i ox query processing
2021 10-13 i ox query processing2021 10-13 i ox query processing
2021 10-13 i ox query processing
 
03 workshop
 03 workshop 03 workshop
03 workshop
 
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
 
Ecto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii BodarevEcto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii Bodarev
 
Yurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSLYurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSL
 
02slide_accessible.pptx
02slide_accessible.pptx02slide_accessible.pptx
02slide_accessible.pptx
 
Functional CNN in elixir
Functional CNN in elixirFunctional CNN in elixir
Functional CNN in elixir
 
Taming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using Telegraf
 
The Ring programming language version 1.10 book - Part 26 of 212
The Ring programming language version 1.10 book - Part 26 of 212The Ring programming language version 1.10 book - Part 26 of 212
The Ring programming language version 1.10 book - Part 26 of 212
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
 
Javascript.ppt
Javascript.pptJavascript.ppt
Javascript.ppt
 
Altinity Quickstart for ClickHouse
Altinity Quickstart for ClickHouseAltinity Quickstart for ClickHouse
Altinity Quickstart for ClickHouse
 
Python basics
Python basicsPython basics
Python basics
 
InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |...
InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |...InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |...
InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |...
 
Complement.pdf
Complement.pdfComplement.pdf
Complement.pdf
 
Timer ppt
Timer pptTimer ppt
Timer ppt
 
F sharp - an overview
F sharp - an overviewF sharp - an overview
F sharp - an overview
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software security
 

Mais de InfluxData

How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
InfluxData
 
How Delft University's Engineering Students Make Their EV Formula-Style Race ...
How Delft University's Engineering Students Make Their EV Formula-Style Race ...How Delft University's Engineering Students Make Their EV Formula-Style Race ...
How Delft University's Engineering Students Make Their EV Formula-Style Race ...
InfluxData
 
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
InfluxData
 
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
InfluxData
 

Mais de InfluxData (20)

Announcing InfluxDB Clustered
Announcing InfluxDB ClusteredAnnouncing InfluxDB Clustered
Announcing InfluxDB Clustered
 
Best Practices for Leveraging the Apache Arrow Ecosystem
Best Practices for Leveraging the Apache Arrow EcosystemBest Practices for Leveraging the Apache Arrow Ecosystem
Best Practices for Leveraging the Apache Arrow Ecosystem
 
How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu...
How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu...How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu...
How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu...
 
Power Your Predictive Analytics with InfluxDB
Power Your Predictive Analytics with InfluxDBPower Your Predictive Analytics with InfluxDB
Power Your Predictive Analytics with InfluxDB
 
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
 
Build an Edge-to-Cloud Solution with the MING Stack
Build an Edge-to-Cloud Solution with the MING StackBuild an Edge-to-Cloud Solution with the MING Stack
Build an Edge-to-Cloud Solution with the MING Stack
 
Meet the Founders: An Open Discussion About Rewriting Using Rust
Meet the Founders: An Open Discussion About Rewriting Using RustMeet the Founders: An Open Discussion About Rewriting Using Rust
Meet the Founders: An Open Discussion About Rewriting Using Rust
 
Introducing InfluxDB Cloud Dedicated
Introducing InfluxDB Cloud DedicatedIntroducing InfluxDB Cloud Dedicated
Introducing InfluxDB Cloud Dedicated
 
Gain Better Observability with OpenTelemetry and InfluxDB
Gain Better Observability with OpenTelemetry and InfluxDB Gain Better Observability with OpenTelemetry and InfluxDB
Gain Better Observability with OpenTelemetry and InfluxDB
 
How a Heat Treating Plant Ensures Tight Process Control and Exceptional Quali...
How a Heat Treating Plant Ensures Tight Process Control and Exceptional Quali...How a Heat Treating Plant Ensures Tight Process Control and Exceptional Quali...
How a Heat Treating Plant Ensures Tight Process Control and Exceptional Quali...
 
How Delft University's Engineering Students Make Their EV Formula-Style Race ...
How Delft University's Engineering Students Make Their EV Formula-Style Race ...How Delft University's Engineering Students Make Their EV Formula-Style Race ...
How Delft University's Engineering Students Make Their EV Formula-Style Race ...
 
Introducing InfluxDB’s New Time Series Database Storage Engine
Introducing InfluxDB’s New Time Series Database Storage EngineIntroducing InfluxDB’s New Time Series Database Storage Engine
Introducing InfluxDB’s New Time Series Database Storage Engine
 
Start Automating InfluxDB Deployments at the Edge with balena
Start Automating InfluxDB Deployments at the Edge with balena Start Automating InfluxDB Deployments at the Edge with balena
Start Automating InfluxDB Deployments at the Edge with balena
 
Understanding InfluxDB’s New Storage Engine
Understanding InfluxDB’s New Storage EngineUnderstanding InfluxDB’s New Storage Engine
Understanding InfluxDB’s New Storage Engine
 
Streamline and Scale Out Data Pipelines with Kubernetes, Telegraf, and InfluxDB
Streamline and Scale Out Data Pipelines with Kubernetes, Telegraf, and InfluxDBStreamline and Scale Out Data Pipelines with Kubernetes, Telegraf, and InfluxDB
Streamline and Scale Out Data Pipelines with Kubernetes, Telegraf, and InfluxDB
 
Ward Bowman [PTC] | ThingWorx Long-Term Data Storage with InfluxDB | InfluxDa...
Ward Bowman [PTC] | ThingWorx Long-Term Data Storage with InfluxDB | InfluxDa...Ward Bowman [PTC] | ThingWorx Long-Term Data Storage with InfluxDB | InfluxDa...
Ward Bowman [PTC] | ThingWorx Long-Term Data Storage with InfluxDB | InfluxDa...
 
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
 
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
 
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
 
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Introduction to Flux and Functional Data Scripting

  • 1. Scott Anderson Sr. Technical Writer & Tech Lead September 2021 Introduction to Flux & Functional Data Scripting
  • 2. © 2021 InfluxData. All rights reserved. 2 What is Flux? A functional data scripting language designed to query, process, and act on data.
  • 3. © 2021 InfluxData. All rights reserved. 3 Design Goals – Turing-complete – Useable – Readable – Flexible – Extensible – Testable – Contributable – Shareable
  • 4. © 2021 InfluxData. All rights reserved. 4 How does it work?
  • 5. © 2021 InfluxData. All rights reserved. 5 © 2021 InfluxData. All rights reserved. 5
  • 6. © 2021 InfluxData. All rights reserved. 6 © 2021 InfluxData. All rights reserved. 6
  • 7. © 2021 InfluxData. All rights reserved. 7 © 2021 InfluxData. All rights reserved. 7
  • 8. © 2021 InfluxData. All rights reserved. 8 © 2021 InfluxData. All rights reserved. 8
  • 9. © 2021 InfluxData. All rights reserved. 9 © 2021 InfluxData. All rights reserved. 9
  • 10. © 2021 InfluxData. All rights reserved. 10 © 2021 InfluxData. All rights reserved. 10
  • 11. © 2021 InfluxData. All rights reserved. 11 © 2021 InfluxData. All rights reserved. 11 from(bucket: "system-data") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent" ) |> aggregateWindow(every: 5m, fn: mean)
  • 12. © 2021 InfluxData. All rights reserved. 12 Data Structure
  • 13. © 2021 InfluxData. All rights reserved. 13 © 2021 InfluxData. All rights reserved. 13
  • 14. © 2021 InfluxData. All rights reserved. 14 © 2021 InfluxData. All rights reserved. 14
  • 15. © 2021 InfluxData. All rights reserved. 15 © 2021 InfluxData. All rights reserved. 15 Stream of tables
  • 16. © 2021 InfluxData. All rights reserved. 16 Table
  • 17. © 2021 InfluxData. All rights reserved. 17 version userID sessionID _field _value Table
  • 18. © 2021 InfluxData. All rights reserved. 18 version userID sessionID _field _value v1 ex123 ex456 example 1.2 v1 ex123 ex456 example 2.2 v1 ex123 ex456 example 2.3 v2 ex123 ex456 example 1.9 v2 ex123 ex456 example 2.5 v2 ex123 ex456 example 3.1 Table
  • 19. © 2021 InfluxData. All rights reserved. 19 version userID sessionID _field _value v1 ex123 ex456 example 1.2 v1 ex123 ex456 example 2.2 v1 ex123 ex456 example 2.3 v2 ex123 ex456 example 1.9 v2 ex123 ex456 example 2.5 v2 ex123 ex456 example 3.1 Table Group key: [ ]
  • 20. © 2021 InfluxData. All rights reserved. 20 version userID sessionID _field _value v1 ex123 ex456 example 1.2 v1 ex123 ex456 example 2.2 v1 ex123 ex456 example 2.3 Tables Group key: ["version", "userID" ] version userID sessionID _field _value v2 ex123 ex456 example 1.9 v2 ex123 ex456 example 2.5 v2 ex123 ex456 example 3.1
  • 21. © 2021 InfluxData. All rights reserved. 21 version userID sessionID _field _value v1 ex123 ex456 example 1.2 v1 ex123 ex456 example 2.2 v1 ex123 ex456 example 2.3 Tables Group key: ["version", "userID" ] version userID sessionID _field _value v2 ex123 ex456 example 1.9 v2 ex123 ex456 example 2.5 v2 ex123 ex456 example 3.1
  • 22. © 2021 InfluxData. All rights reserved. 22 © 2021 InfluxData. All rights reserved. 22 sql.from( driverName: "mysql", dataSourceName: "${username}:${password}@tcp(localhost:3306)/db", query:"SELECT CustomerName,City FROM Customers;" ) CustomerName City John Doe New York Jane Seymour London Rufus Peck San Francisco Group key: [ ]
  • 23. © 2021 InfluxData. All rights reserved. 23 © 2021 InfluxData. All rights reserved. 23 from(bucket: "example-bucket") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "m1" and r.field == "f1") _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z m1 host1 f1 1.2 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z m1 host1 f1 2.5 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z m1 host1 f1 2.2 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z m1 host2 f1 1.2 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z m1 host2 f1 2.5 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z m1 host2 f1 2.2 Group key: ["_start", "_stop", "_measurement", "host", "_field"]
  • 24. © 2021 InfluxData. All rights reserved. 24 Flux Syntax
  • 25. © 2021 InfluxData. All rights reserved. 25 © 2021 InfluxData. All rights reserved. 25 Pipe-forward |>
  • 26. © 2021 InfluxData. All rights reserved. 26 © 2021 InfluxData. All rights reserved. 26 Basic data types string "example string" bool true float 1.20 int 123456789 uint 123456789 duration 1h time 2019-12-01T00:00:00Z bytes [104 101 108 108 111]
  • 27. © 2021 InfluxData. All rights reserved. 27 © 2021 InfluxData. All rights reserved. 27 Composite data types record {key1: "value1", key2: 2.0} array [12, 34, 56] dict [1: "foo", 2: "bar"] function f = (x) => x
  • 28. © 2021 InfluxData. All rights reserved. 28 © 2021 InfluxData. All rights reserved. 28 Variable declarations varName = varValue foo = "bar" bazRecord = {this: 1, that: 8} data = from(...)
  • 29. © 2021 InfluxData. All rights reserved. 29 © 2021 InfluxData. All rights reserved. 29 Reference composite types r = {key1: "value1", key2: 2.0} Dot notation r.key1 Returns "value1" Bracket notation r["key1"] Returns "value1"
  • 30. © 2021 InfluxData. All rights reserved. 30 © 2021 InfluxData. All rights reserved. 30 Reference composite types arr = [12, 34, 56] Bracket notation arr[0] Returns 12
  • 31. © 2021 InfluxData. All rights reserved. 31 © 2021 InfluxData. All rights reserved. 31 Reference composite types dictEx = [1: "foo", 2: "bar"] Function reference dict.get(dict: dictEx, key: 1, default: "baz") Returns "foo"
  • 32. © 2021 InfluxData. All rights reserved. 32 © 2021 InfluxData. All rights reserved. 32 Reference composite types dictEx = [1: "foo", 2: "bar"] Function reference dict.get(dict: dictEx, key: 3, default: "baz") Returns "baz"
  • 33. © 2021 InfluxData. All rights reserved. 33 © 2021 InfluxData. All rights reserved. 33 Reference composite types r = {key1: "value1", key2: 2.0} key = "key1" r.key Returns an error r["key"] Returns an error r["${key}"] Returns an error r = ["key1": "value1", "key2": "2.0"] key = "key1" dict.get( dict: r, key: key, default: "" ) Returns "value1"
  • 34. © 2021 InfluxData. All rights reserved. 34 © 2021 InfluxData. All rights reserved. 34 Functions f = (x, y) => x / y f(x: 12, y: 2) Returns 6
  • 35. © 2021 InfluxData. All rights reserved. 35 © 2021 InfluxData. All rights reserved. 35 Function types Static f = (x, y=2) => x / y Transformation f = (t=<-) => t Predicate (r) => r.key1 == "foo"
  • 36. © 2021 InfluxData. All rights reserved. 36 © 2021 InfluxData. All rights reserved. 36 Predicate functions (r) => 1.0 == 1.0 Parameter(s) Predicate Expression
  • 37. © 2021 InfluxData. All rights reserved. 37 © 2021 InfluxData. All rights reserved. 37 Predicate functions (r) => true
  • 38. © 2021 InfluxData. All rights reserved. 38 © 2021 InfluxData. All rights reserved. 38 Predicate functions (r) => 1.0 != 1.0
  • 39. © 2021 InfluxData. All rights reserved. 39 © 2021 InfluxData. All rights reserved. 39 Predicate functions (r) => false
  • 40. © 2021 InfluxData. All rights reserved. 40 © 2021 InfluxData. All rights reserved. 40 { Predicate functions (r) => 1.0 > 1.0 == != < > <= >= =~ !~
  • 41. © 2021 InfluxData. All rights reserved. 41 © 2021 InfluxData. All rights reserved. 41 Predicate functions (r) => 1.0 == 1.0 and "foo" != "bar"
  • 42. © 2021 InfluxData. All rights reserved. 42 © 2021 InfluxData. All rights reserved. 42 Predicate functions (r) => true and true
  • 43. © 2021 InfluxData. All rights reserved. 43 © 2021 InfluxData. All rights reserved. 43 Predicate functions (r) => true
  • 44. © 2021 InfluxData. All rights reserved. 44 © 2021 InfluxData. All rights reserved. 44 Predicate functions (r) => 1.0 > 1.0 and "foo" != "bar"
  • 45. © 2021 InfluxData. All rights reserved. 45 © 2021 InfluxData. All rights reserved. 45 Predicate functions (r) => false and true
  • 46. © 2021 InfluxData. All rights reserved. 46 © 2021 InfluxData. All rights reserved. 46 Predicate functions (r) => false
  • 47. © 2021 InfluxData. All rights reserved. 47 © 2021 InfluxData. All rights reserved. 47 Predicate functions (r) => 1.0 > 1.0 or "foo" != "bar"
  • 48. © 2021 InfluxData. All rights reserved. 48 © 2021 InfluxData. All rights reserved. 48 Predicate functions (r) => true
  • 49. © 2021 InfluxData. All rights reserved. 49 © 2021 InfluxData. All rights reserved. 49 Predicate functions (r) => 1.0 == 1.0 and ("foo" == "bar" or "baz" != "quz")
  • 50. © 2021 InfluxData. All rights reserved. 50 © 2021 InfluxData. All rights reserved. 50 Predicate functions r = {fname: "John", lname: "Doe", age: 42} (r) => r.fname == "John" and r.age > 40
  • 51. © 2021 InfluxData. All rights reserved. 51 © 2021 InfluxData. All rights reserved. 51 Predicate functions r = {fname: "Mike", lname: "Smith", age: 29} (r) => r.fname == "John" and r.age > 40
  • 52. © 2021 InfluxData. All rights reserved. 52 Basic Query
  • 53. © 2021 InfluxData. All rights reserved. 53 © 2021 InfluxData. All rights reserved. 53 Basic Query from(bucket: "system-data") Source
  • 54. © 2021 InfluxData. All rights reserved. 54 © 2021 InfluxData. All rights reserved. 54 Basic Query sql.from( driverName: "postgres", dataSourceName: "...", query: "..." ) Source
  • 55. © 2021 InfluxData. All rights reserved. 55 © 2021 InfluxData. All rights reserved. 55 Basic Query csv.from(csv: "...") Source
  • 56. © 2021 InfluxData. All rights reserved. 56 © 2021 InfluxData. All rights reserved. 56 Basic Query from(bucket: "system-data") Source
  • 57. © 2021 InfluxData. All rights reserved. 57 © 2021 InfluxData. All rights reserved. 57 Basic Query from(bucket: "system-data") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent") Source Filter
  • 58. © 2021 InfluxData. All rights reserved. 58 © 2021 InfluxData. All rights reserved. 58 Basic Query from(bucket: "system-data") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent") |> group(columns: ["host"]) Source Filter Shape
  • 59. © 2021 InfluxData. All rights reserved. 59 © 2021 InfluxData. All rights reserved. 59 Basic Query from(bucket: "system-data") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent") |> group(columns: ["host"]) |> mean() Source Filter Shape Process
  • 60. © 2021 InfluxData. All rights reserved. 60 © 2021 InfluxData. All rights reserved. 60 Basic Query from(bucket: "system-data") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent") |> group(columns: ["host"]) |> mean() Source Filter Shape Process
  • 61. © 2021 InfluxData. All rights reserved. 61 © 2021 InfluxData. All rights reserved. 61 Process Data data = from(bucket: "system-data") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent" )
  • 62. © 2021 InfluxData. All rights reserved. 62 © 2021 InfluxData. All rights reserved. 62 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 62.1 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 63.8 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 44.0 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7 Process Data
  • 63. © 2021 InfluxData. All rights reserved. 63 © 2021 InfluxData. All rights reserved. 63 Process Data data |> map(fn: (r) => ({_time: r._time, _value: r._value}))
  • 64. © 2021 InfluxData. All rights reserved. 64 © 2021 InfluxData. All rights reserved. 64 _time _value 2021-01-01T00:09:00Z 62.1 2021-01-01T00:18:00Z 44.0 2021-01-01T00:24:00Z 52.4 2021-01-01T00:28:00Z 63.8 2021-01-01T00:39:00Z 65.4 2021-01-01T00:42:00Z 50.7 Process Data
  • 65. © 2021 InfluxData. All rights reserved. 65 © 2021 InfluxData. All rights reserved. 65 Process Data data |> map(fn: (r) => ({r with _value: r._value * 0.01}))
  • 66. © 2021 InfluxData. All rights reserved. 66 © 2021 InfluxData. All rights reserved. 66 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 0.621 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 0.638 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 0.654 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 0.44 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 0.524 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 0.507 Process Data
  • 67. © 2021 InfluxData. All rights reserved. 67 © 2021 InfluxData. All rights reserved. 67 Process Data data |> map(fn: (r) => ({ r with state: if r._value > 65.0 then "high" else "ok" }))
  • 68. © 2021 InfluxData. All rights reserved. 68 © 2021 InfluxData. All rights reserved. 68 _start _stop _time _measurement host _field _value state 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 62.1 ok 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 63.8 ok 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4 high _start _stop _time _measurement host _field _value state 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 44.0 ok 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4 ok 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7 ok Process Data
  • 69. © 2021 InfluxData. All rights reserved. 69 © 2021 InfluxData. All rights reserved. 69 Process Data data |> mean()
  • 70. © 2021 InfluxData. All rights reserved. 70 |> mean()
  • 71. © 2021 InfluxData. All rights reserved. 71 © 2021 InfluxData. All rights reserved. 71 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:09:00Z mem host1 used_percent 62.1 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:28:00Z mem host1 used_percent 63.8 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:18:00Z mem host2 used_percent 44.0 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7 Process Data
  • 72. © 2021 InfluxData. All rights reserved. 72 © 2021 InfluxData. All rights reserved. 72 _start _stop _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host1 used_percent 63.8 _start _stop _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host2 used_percent 49.0 Process Data
  • 73. © 2021 InfluxData. All rights reserved. 73 © 2021 InfluxData. All rights reserved. 73 Process Data data |> sum()
  • 74. © 2021 InfluxData. All rights reserved. 74 © 2021 InfluxData. All rights reserved. 74 _start _stop _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host1 used_percent 191.3 _start _stop _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z mem host2 used_percent 147.1 Process Data
  • 75. © 2021 InfluxData. All rights reserved. 75 © 2021 InfluxData. All rights reserved. 75 Process Data data |> max()
  • 76. © 2021 InfluxData. All rights reserved. 76 © 2021 InfluxData. All rights reserved. 76 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:24:00Z mem host2 used_percent 52.4 Process Data
  • 77. © 2021 InfluxData. All rights reserved. 77 © 2021 InfluxData. All rights reserved. 77 Process Data data |> last()
  • 78. © 2021 InfluxData. All rights reserved. 78 © 2021 InfluxData. All rights reserved. 78 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:39:00Z mem host1 used_percent 65.4 _start _stop _time _measurement host _field _value 2021-01-01T00:00:00Z 2021-01-01T01:00:00Z 2021-01-01T00:42:00Z mem host2 used_percent 50.7 Process Data
  • 79. © 2021 InfluxData. All rights reserved. 79 Flux in Practice
  • 80. © 2021 InfluxData. All rights reserved. 80 © 2021 InfluxData. All rights reserved. 80 from(bucket: "market-summary") |> range(start: -6mo) |> filter(fn: (r) => r._measurement == "stockPrices" and r.symbol == "GME" ) |> holtWinters(n: 24, seasonality: 12, interval: 1w)
  • 81. © 2021 InfluxData. All rights reserved. 81 © 2021 InfluxData. All rights reserved. 81 heatIndex = (t, h) => //... from(bucket: "sensor-data") |> range(start: -1d) |> filter(fn: (r) => r._measurement == "sensors") |> filter(fn: (r) => r._field == "temp" or r._field == "hum") |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") |> map(fn: (r) => ({ r with heatIndex: heatIndex(t: r.temp, h: r.hum) }))
  • 82. © 2021 InfluxData. All rights reserved. 82 © 2021 InfluxData. All rights reserved. 82 import "sql" sensorInfo = sql.from( driverName: "postgres", dataSourceName: "postgresql://localhost?sslmode=disable", query: "SELECT * FROM sensors" ) sensorMetrics = from(bucket: "example-bucket") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "airSensors") join(tables: {metric: sensorMetrics, info: sensorInfo}, on: ["sensor_id"]) |> group(columns: ["sensor_id", "lastInspected"]), |> aggregateWindow( every: 5m, fn: (tables=<-, column="error") => tables |> count(column: column) )
  • 84. October 11-12, 2021 Hands-On Flux Training October 26-27, 2021 Virtual Experience We look forward to bringing together our community of developers to learn, interact and share tips and use cases. https://www.influxdays.com/influxdays-north-america-2021-virtual-experience/