In this talk we’ll learn about some of the biggest challenges beginner Flux users face. We’ll also learn about resources and tools that developers can take advantage of to become a Flux Pro.
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Anais Dotis-Georgiou [InfluxData] | Becoming a Flux Pro | InfluxDays 2022
1.
2. Becoming a Flux Pro
Anais Dotis-Georgiou
Developer Advocate, InfluxData
3. Connect Learn Build
Hear from and meet developers
from the InfluxDB Community
Be inspired by use cases from
our partners and InfluxDB engineers
Learn best practices that will
help you build great experiences
for your projects
4. In this talk we’ll learn about some of the biggest
challenges beginner Flux users face. We’ll also learn
about resources and tools that developers can take
advantage of to become a Flux Pro.
Anais Dotis-Georgiou
Lead Developer Advocate
Anais Dotis-Georgiou is a developer advocate at
InfluxData with a passion for making data beautiful
using data analytics, AI, and machine learning. She
takes the data that she collects and does a mix of
research, exploration, and engineering to translate the
data into something of function, value, and beauty.
Becoming a Flux Pro
5. Agenda
1. Understanding critical functions
2. Utilizing existing tools to expedite learning
3. Taking advantage of learning resources
6. From Series to Tables on Disk
measurement1 field1=1i,field2=1,field3="a"
measurement1 field1=1i,field2=2,field3="b"
7. Grouping
• Flux operates on streams of tables.
• Every table has a group key – a list of columns for which every
row in the table has the same value. Tables are defined by their
group keys.
• You can use Flux to combine or divide tables.
12. Not in
Group Key
In Group Key In Group
Key
Not in
Group
Key
In Group Key In Group Key In Group Key Not in Group
Key
table
before
_measurement _field _value location _start _stop _time
0 average_temperature temperature 82.0 coyote_creek rfc3339startTime rfc3339stopTime rfc3339time1
0 average_temperature temperature 73.0 coyote_creek rfc3339startTime rfc3339stopTime rfc3339time2
0 average_temperature temperature 86.0 coyote_creek rfc3339startTime rfc3339stopTime rfc3339time3
1 average_temperature temperature 85.0 santa_monica rfc3339startTime rfc3339stopTime rfc3339time1
1 average_temperature temperature 74.0 santa_monica rfc3339startTime rfc3339stopTime rfc3339time2
1 average_temperature temperature 80.0 santa_monica rfc3339startTime rfc3339stopTime rfc3339time3
13. Not in Group
Key
In Group Key Not In Group
Key
Not in
Group
Key
Not In Group
Key
Not In Group Key Not In Group Key Not in Group
Key
table
group on
measurement
_measurement _field _value location _start _stop _time
0 average_tempera
ture
temperature 82.0 coyote_creek rfc3339startTime rfc3339stopTime rfc3339time1
0 average_tempera
ture
temperature 73.0 coyote_creek rfc3339startTime rfc3339stopTime rfc3339time2
0 average_tempera
ture
temperature 86.0 coyote_creek rfc3339startTime rfc3339stopTime rfc3339time3
0 average_tempera
ture
temperature 85.0 santa_monica rfc3339startTime rfc3339stopTime rfc3339time1
0 average_tempera
ture
temperature 74.0 santa_monica rfc3339startTime rfc3339stopTime rfc3339time2
0 average_tempera
ture
temperature 80.0 santa_monica rfc3339startTime rfc3339stopTime rfc3339time3
15. Not in
Group Key
In Group Key Not in
Group
Key
table
mean
_measurement _value
0 average_temperature 80.0
16. Embracing
experimentation
• Learning a new language involves embracing
experimentation. Understanding happens through
trial and error.
• Tools that facilitate experimentation:
• InfluxDB UI
• Flux extension for VS Code
29. How do I calculate the
difference in temp across
both locations?
30. Not in
Group Key
In Group Key In Group Key Not in
Group
Key
In Group Key In Group Key in Group Key Not in Group
Key
table
raw
_measurement _field _value generatorID topic host _time
0 genData temperature 190.0 generator1 emergency_gen
erator/generator
1
influxdata-roads
how
rfc3339time1
0 genData temperature 195.0 generator1 emergency_gen
erator/generator
1
influxdata-roads
how
rfc3339time2
1 genData temperature 200.0 generator2 emergency_gen
erator/generator
2
influxdata-roads
how
rfc3339time1
1 genData temperature 210.0 generator2 emergency_gen
erator/generator
2
influxdata-roads
how
rfc3339time2
32. Not in
Group Key
In Group Key In Group Key Not in
Group Key
Not in Group
Key
In Group Key in Group Key Not in Group
Key
table
pivoted
_measurement _field generator1 generator2 topic host _time
0 genData temperature 190.0 200.0 emergency_gene
rator/generator1
influxdata-roadsh
ow
rfc3339time1
0 genData temperature 195.0 210.0 emergency_gene
rator/generator1
influxdata-roadsh
ow
rfc3339time2
33. map
difference = pivot
|> map(fn: (r) => ({ r with difference: r.generator1 -
r.generator2 }))
|> yield(name: "difference")
34. Not in
Group Key
In Group Key In Group Key Not in
Group Key
Not in Group
Key
Not in Group
Key
In Group Key in Group Key Not in Group
Key
table
pivoted
_measurement _field generator1 generator2 difference topic host _time
0 genData temperature 190.0 200.0 -10.0 emergency_ge
nerator/generat
or1
influxdata-road
show
rfc3339time1
0 genData temperature 195.0 210.0 -15.0 emergency_ge
nerator/generat
or1
influxdata-road
show
rfc3339time2
//use the math.abs() function to get the absolute difference
|> map(fn: (r) => ({ r with difference: math.abs(x: r.generator1 -
r.generator2 )}))