Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux Beginners | InfluxDays Virtual Experience NA 2020

InfluxData
InfluxDataInfluxData
Faith Chikwekwe, InfluxData
Anais Dotis-Georgiou, InfluxData
Top 10 Hurdles for
Flux Beginners
Introduction and Overview
Flux
© 2020 InfluxData. All rights reserved. 3
Introduction to Flux
● Functional query and
scripting language
● JavaScript-esque
● Open source
● Written in Go and Flux itself
from(bucket:"example-bucket")
|> range(start:-1h)
|> filter(fn:(r) =>
r._measurement == "cpu" and
r.cpu == "cpu-total"
)
© 2020 InfluxData. All rights reserved. 4
Introduction to Flux
● Math across Measurements
● Custom Functions
● SPEC and syntax examples available in repo
github.com/influxdata/flux/SPEC.md
1.Overlooking UI tools
which facilitate writing
Flux
© 2020 InfluxData. All rights reserved. 6
Using the UI–Solution
● Using the Flux Script Editor
● Using the Raw Data View
© 2020 InfluxData. All rights reserved. 7
● Using the Flux Script Editor
● Variables
Using the Flux Builder
© 2020 InfluxData. All rights reserved. 8
● Using the Flux Script Editor
● Variables
Injecting Functions
© 2020 InfluxData. All rights reserved. 9
Table View vs Raw Data View
© 2020 InfluxData. All rights reserved. 10
Using the Raw Data View
2. Folks misunderstand
annotated CSVs and
sometimes don’t write
them correctly.
© 2020 InfluxData. All rights reserved. 12
● array.from()
● to()
● Use github.com/influxdata/flux/stdlib/universe
Annotated CSV Solutions
© 2020 InfluxData. All rights reserved. 13
© 2020 InfluxData. All rights reserved. 14
from(bucket: "cats-and-dogs")
|> range(start: 2020-05-15T00:00:00Z, stop: 2020-05-16T00:00:00Z)
|> filter(fn: (r) => r["_measurement"] == "cats")
|> filter(fn: (r) => r["_field"] == "adult")
|> filter(fn: (r) => r["shelter"] == "A")
|> filter(fn: (r) => r["type"] == "calico")
|> limit(n:2)
#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,shelter,type
,,0,2020-05-15T00:00:00Z,2020-05-16T00:00:00Z,2020-05-15T18:50:33.262484Z,8,adult,cats,A,calico
,,0,2020-05-15T00:00:00Z,2020-05-16T00:00:00Z,2020-05-15T18:51:48.852085Z,7,adult,cats,A,calico
© 2020 InfluxData. All rights reserved. 15
Explaining Annotated CSV
● #group: A boolean that indicates the column is part of the group key. A group key
is a list of columns for which every row in the table has the same value.
○ true columns: In our example query above, we’ve filtered by a single field
type, adult, a single “shelter” tag, “A”, and a single “type” tag, “calico”. These
values are constant across rows, so those columns are set to true.
○ false columns: The _time and _value columns have different values values
across rows which is why they receive a false for the value of the #group
Annotation.
● #datatype: Describes the type of data.
● #default: The value to use for rows with an empty value. So for example, if we
had assigned our query to the variable ourQuery this annotation would look like:
#default,ourQuery,,,,,,,,,
© 2020 InfluxData. All rights reserved. 16
import "experimental/array"
array.from(rows: [{_measurement: "m0", mytag: "t0", _field: "f0", _value: "foo", _time: 2020-01-
01T00:00:00Z,},
{_measurement: "m0", mytag: "t0", _field: "f0", _value: "bar", _time: 2020-01-
02T00:00:00Z}])
|> to(bucket: “my-bucket”)
Using array.from()
3. Data layout design
leads to runaway
cardinality and slow Flux
queries
© 2020 InfluxData. All rights reserved. 18
Influx Line Protocol
© 2020 InfluxData. All rights reserved. 19
General Recommendations
● Encode meta data in tags. Measurements and tags are
indexed while field values are not. Commonly queried
metadata should be stored in tags.
● Limit the number of series or try to reduce series
cardinality.
● Keep bucket and measurement names short and simple.
● Avoid encoding data in measurement names.
● Separate data into buckets when you need to assign
different retention policies to that data or require an
authentication token.
© 2020 InfluxData. All rights reserved. 20
Common Mistakes
Mistake: Making ids (such as eventid, orderid, or userid) a tag.
This is another example that can cause unbounded cardinality
if the tag values aren’t scoped.
Solution: Instead, make these metrics a field.
© 2020 InfluxData. All rights reserved. 21
Schema and Flux
● Your schema affects your Flux query performance.
● Anticipate common queries and let that influence your
schema design.
4. Storing the wrong data
in InfluxDB and under-
utilizing Source Functions
© 2020 InfluxData. All rights reserved. 23
● Use Source functions to pull relevant data into InfluxDB as
needed
● Work with PostgreSQL, MySQL, Snowflake, SQLite, SQL
Server, Athena, BigQuery
Source Functions – Solution
© 2020 InfluxData. All rights reserved. 24
import "sql"
sql.from(
driverName: "postgres",
dataSourceName: "postgresql://user:password@localhost",
query: "SELECT * FROM example_table"
)
Source Functions – Solution
5. Confused about how to
project multiple
aggregations
© 2020 InfluxData. All rights reserved. 26
● Create multiple queries with the UI and visualize them
simultaneously
● Get “Fancy” with Flux to project multiple aggregations
○ join()
○ pivot() and union()
○ reduce()
Multiple Aggregation Projections – Solutions
© 2020 InfluxData. All rights reserved. 27
Multiple Aggregation with the UI
© 2020 InfluxData. All rights reserved. 28
data = from(bucket: "my-bucket")
|> range(start: 2019-12-31T00:00:00Z, stop: 2020-01-04T00:00:00Z)
|> filter(fn: (r) => r._measurement == "my_measurement")
|> filter(fn: (r) => r._field == "temp")
temp_mean = data
|> mean()
|> set(key: "agg_type", value: "mean")
temp_count = data
|> count()
|> toFloat()
|> set(key: "agg_type", value: "count")
union(tables: [temp_mean, temp_count])
|> group(columns: ["agg_type"], mode:"by")
|> yield()
Union
© 2020 InfluxData. All rights reserved. 29
● The join() function merges two or more input streams,
whose values are equal on a set of common columns, into a
single output stream.
● The reduce() function aggregates records in each table
according to the reducer, fn, providing a way to create
custom aggregations.
Join and Reduce
6. Common Flux Packages
and Utility Functions
Not knowing beginner tips to make writing Flux easier
© 2020 InfluxData. All rights reserved. 31
Common Flux Packages and Utility Functions
aggregateWindow() Create your own utility function to aggregate data
for your use case and pass it in as the `fn` param
monitor package Write your own check and notification scripts for
greater control over alerts `flux/docs/Alerts.md`
map() Replace the value in a column (for example
offsetting the `_value` column) using the with
keyword
I need more functionality for my
use case
Consider contributing a custom package to Flux
flux/stdlib/contrib/README.md
© 2020 InfluxData. All rights reserved. 32
Custom Aggregate
custom_agg = …
from(bucket:"items")
|> range(start:-1h)
|> aggregateWindow(every: 1m, fn: custom_agg)
Map
from(bucket: “items”)
|> filter(fn: (r) => r._measurement == "m")
|> map(fn: (r) => ({r with _value: r._value * 2.0} ))
© 2020 InfluxData. All rights reserved. 33
Median Absolute Deviation with Flux
7. Performance Gains
Being unaware of awesome performance
optimizations to make your queries faster in
InfluxDB Cloud 2.0
© 2020 InfluxData. All rights reserved. 35
- Memory optimizations
- More pushdowns
- What’s a pushdown?
- “Pushing down” the work of transforming the data to be
done by the storage side
- How does it help optimize my query?
Performance Gains
© 2020 InfluxData. All rights reserved. 36
Query You have some data stored in InfluxDB Cloud 2.0. You write a
query for that data. (e.g. from |> range |> filter |> group |> max)
Plan The Flux planner will check if your query matches any
existing pushdown patterns.
Rewrite If it matches a pushdown pattern, then the planner
will write the plan for how to perform your query.
Execute
The Flux executor will execute your query by
invoking a hidden operation (e.g. ReadGroupMax).
This will initiate a storage read API call.
Result
Storage will transform the data and stream
the result back to Flux via gRPC. Flux converts
the gRPC data back to Flux tables.
© 2020 InfluxData. All rights reserved. 37
Assuming your query starts with:
- from() |> range() |> filter() [these get pushed down]
We’re supporting the following in InfluxDB Cloud 2.0:
- Bare aggregates
- e.g.|> first()
- Windowed aggregates
- e.g.|> window() |> first
- |> aggregateWindow(first)
- Grouped aggregates
- e.g. |> group() |> first()
- |> group() |> window() |> first()
Performance Gains
8. Schema Mutations
Not using schema mutators at the right time
© 2020 InfluxData. All rights reserved. 39
from(bucket: “itemBucket”)
|> range(start: -1mo)
|> filter(fn: (r) => (r._measurement == “rate”))
|> filter(fn: (r) => (r._field == “item1”))
|> mean()
...
|> drop(columns: [“col1”, “col2”])
keep(), drop(), rename(), duplicate()
Schema Mutations
9. Tasks
When to write your own tasks
© 2020 InfluxData. All rights reserved. 41
How to write a Task
© 2020 InfluxData. All rights reserved. 42
option task = {name: “rateTask”, every: 1h}
rate = from(bucket: “items”)
|> range(start: -task.every)
|> filter(fn: (r) => (r._measurement == “totalItems”))
|> filter(fn: (r) => (r._field == “items”))
|> group(columns: [“itemGroupName”])
|> aggregateWindow(fn: sum, every: task.every)
|> map(fn: (r) => {
return: _time: r._time, _stop: r._stop, _start: r._start, _measurement: “rateTask”, _field: “fruits”, _value: r._value,
itemGroupName: itemGroupName,
}
})
rate
|> to(bucket: “newItems”)
How to write a Task
© 2020 InfluxData. All rights reserved. 43
from(bucket: “newItems”)
|> range(start: -1mo)
|> filter(fn: (r) => (r._measurement == “rateTask”))
|> filter(fn: (r) => (r._field == “items”))
Output Task Data to a Dashboard
Examples for how to write a check and notification script are in
flux/doc/Alerts.md.
You can even write your own alerts
10. Downsampling Tasks
Not knowing when/why to downsample data
© 2020 InfluxData. All rights reserved. 45
options task = {name: “foo”, every: 1m}
from(bucket: “items”)
|> range(start: -task.every)
|> filter(fn: r._measurement == "m" and r._field == "f")
|> group(columns: ["_measurement", "_field", "_start", "_stop"])
|> aggregateWindow(fn: last, every: task.every)
|> to(bucket: "downsample_bucket")
Why Downsample?
© 2020 InfluxData. All rights reserved. 46
option task = {name: "Downsampling CPU", every: 1m}
data = from(bucket: "my-bucket")
|> range(start: -task.every)
|> filter(fn: (r) => r._measurement == "my_measurement")
data
|> mean()
|> set(key: "agg_type",value: "mean_temp")
|> to(bucket: "downsampled", org: "my-org", tagColumns: ["agg_type"])
data
|> count()
|> set(key: "agg_type",value: “count_temp")
|> to(bucket: "downsampled", org: "my-org", tagColumns: ["agg_type"])
Why Downsample?
© 2020 InfluxData. All rights reserved. 47
Thanks!
1 of 47

Recommended

Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa... by
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...InfluxData
136 views59 slides
Taming the Tiger: Tips and Tricks for Using Telegraf by
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 TelegrafInfluxData
146 views91 slides
Barbara Nelson [InfluxData] | How Can I Put That Dashboard in My App? | Influ... by
Barbara Nelson [InfluxData] | How Can I Put That Dashboard in My App? | Influ...Barbara Nelson [InfluxData] | How Can I Put That Dashboard in My App? | Influ...
Barbara Nelson [InfluxData] | How Can I Put That Dashboard in My App? | Influ...InfluxData
118 views27 slides
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi by
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiInfluxData
228 views47 slides
Scaling up data science applications by
Scaling up data science applicationsScaling up data science applications
Scaling up data science applicationsKexin Xie
123 views41 slides
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In... by
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...InfluxData
566 views23 slides

More Related Content

What's hot

Time Series Meetup: Virtual Edition | July 2020 by
Time Series Meetup: Virtual Edition | July 2020Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020InfluxData
190 views29 slides
InfluxData Platform Future and Vision by
InfluxData Platform Future and VisionInfluxData Platform Future and Vision
InfluxData Platform Future and VisionInfluxData
204 views142 slides
Monitoring InfluxEnterprise by
Monitoring InfluxEnterpriseMonitoring InfluxEnterprise
Monitoring InfluxEnterpriseInfluxData
654 views31 slides
Flux and InfluxDB 2.0 by Paul Dix by
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixInfluxData
1.3K views85 slides
JS Fest 2019. Anjana Vakil. Serverless Bebop by
JS Fest 2019. Anjana Vakil. Serverless BebopJS Fest 2019. Anjana Vakil. Serverless Bebop
JS Fest 2019. Anjana Vakil. Serverless BebopJSFestUA
521 views57 slides
Goal Based Data Production with Sim Simeonov by
Goal Based Data Production with Sim SimeonovGoal Based Data Production with Sim Simeonov
Goal Based Data Production with Sim SimeonovDatabricks
803 views42 slides

What's hot(20)

Time Series Meetup: Virtual Edition | July 2020 by InfluxData
Time Series Meetup: Virtual Edition | July 2020Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020
InfluxData190 views
InfluxData Platform Future and Vision by InfluxData
InfluxData Platform Future and VisionInfluxData Platform Future and Vision
InfluxData Platform Future and Vision
InfluxData204 views
Monitoring InfluxEnterprise by InfluxData
Monitoring InfluxEnterpriseMonitoring InfluxEnterprise
Monitoring InfluxEnterprise
InfluxData654 views
Flux and InfluxDB 2.0 by Paul Dix by InfluxData
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul Dix
InfluxData1.3K views
JS Fest 2019. Anjana Vakil. Serverless Bebop by JSFestUA
JS Fest 2019. Anjana Vakil. Serverless BebopJS Fest 2019. Anjana Vakil. Serverless Bebop
JS Fest 2019. Anjana Vakil. Serverless Bebop
JSFestUA521 views
Goal Based Data Production with Sim Simeonov by Databricks
Goal Based Data Production with Sim SimeonovGoal Based Data Production with Sim Simeonov
Goal Based Data Production with Sim Simeonov
Databricks803 views
WattGo: Analyses temps-réél de series temporelles avec Spark et Solr (Français) by DataStax Academy
WattGo: Analyses temps-réél de series temporelles avec Spark et Solr (Français)WattGo: Analyses temps-réél de series temporelles avec Spark et Solr (Français)
WattGo: Analyses temps-réél de series temporelles avec Spark et Solr (Français)
DataStax Academy830 views
Exploring Modeling - Doing More with Lists by Ronen Botzer
Exploring Modeling - Doing More with ListsExploring Modeling - Doing More with Lists
Exploring Modeling - Doing More with Lists
Ronen Botzer455 views
Introduction to Flux and Functional Data Scripting by InfluxData
Introduction to Flux and Functional Data ScriptingIntroduction to Flux and Functional Data Scripting
Introduction to Flux and Functional Data Scripting
InfluxData243 views
Time Series Analysis for Network Secruity by mrphilroth
Time Series Analysis for Network SecruityTime Series Analysis for Network Secruity
Time Series Analysis for Network Secruity
mrphilroth6.3K views
RxJS - The Reactive extensions for JavaScript by Viliam Elischer
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
Viliam Elischer915 views
Hive Functions Cheat Sheet by Hortonworks
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
Hortonworks9.3K views
Business Dashboards using Bonobo ETL, Grafana and Apache Airflow by Romain Dorgueil
Business Dashboards using Bonobo ETL, Grafana and Apache AirflowBusiness Dashboards using Bonobo ETL, Grafana and Apache Airflow
Business Dashboards using Bonobo ETL, Grafana and Apache Airflow
Romain Dorgueil2.8K views
Making Nested Columns as First Citizen in Apache Spark SQL by Databricks
Making Nested Columns as First Citizen in Apache Spark SQLMaking Nested Columns as First Citizen in Apache Spark SQL
Making Nested Columns as First Citizen in Apache Spark SQL
Databricks2.3K views
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith... by Data Con LA
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Data Con LA1.3K views
ComputeFest 2012: Intro To R for Physical Sciences by alexstorer
ComputeFest 2012: Intro To R for Physical SciencesComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical Sciences
alexstorer470 views
HyperLogLog in Hive - How to count sheep efficiently? by bzamecnik
HyperLogLog in Hive - How to count sheep efficiently?HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?
bzamecnik4.7K views
Writing Hadoop Jobs in Scala using Scalding by Toni Cebrián
Writing Hadoop Jobs in Scala using ScaldingWriting Hadoop Jobs in Scala using Scalding
Writing Hadoop Jobs in Scala using Scalding
Toni Cebrián2.9K views
Statsd introduction by Rick Chang
Statsd introductionStatsd introduction
Statsd introduction
Rick Chang3.7K views

Similar to Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux Beginners | InfluxDays Virtual Experience NA 2020

Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi... by
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...InfluxData
517 views30 slides
Webinar: ArangoDB 3.8 Preview - Analytics at Scale by
Webinar: ArangoDB 3.8 Preview - Analytics at Scale Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale ArangoDB Database
643 views29 slides
Apache Spark Streaming: Architecture and Fault Tolerance by
Apache Spark Streaming: Architecture and Fault ToleranceApache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault ToleranceSachin Aggarwal
3.7K views57 slides
Lambdas puzzler - Peter Lawrey by
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyJAXLondon_Conference
673 views47 slides
InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |... by
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 |...InfluxData
355 views59 slides
Advanced kapacitor by
Advanced kapacitorAdvanced kapacitor
Advanced kapacitorInfluxData
5.6K views53 slides

Similar to Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux Beginners | InfluxDays Virtual Experience NA 2020(20)

Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi... by InfluxData
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...
InfluxData517 views
Webinar: ArangoDB 3.8 Preview - Analytics at Scale by ArangoDB Database
Webinar: ArangoDB 3.8 Preview - Analytics at Scale Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
ArangoDB Database643 views
Apache Spark Streaming: Architecture and Fault Tolerance by Sachin Aggarwal
Apache Spark Streaming: Architecture and Fault ToleranceApache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault Tolerance
Sachin Aggarwal3.7K views
InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |... by InfluxData
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 |...
InfluxData355 views
Advanced kapacitor by InfluxData
Advanced kapacitorAdvanced kapacitor
Advanced kapacitor
InfluxData5.6K views
Performance measurement and tuning by AOE
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE 1.4K views
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData by InfluxData
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxDataBuilding a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
InfluxData944 views
How to Build a Telegraf Plugin by Noah Crowley by InfluxData
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
InfluxData3.4K views
Write your own telegraf plugin by InfluxData
Write your own telegraf pluginWrite your own telegraf plugin
Write your own telegraf plugin
InfluxData13.8K views
Spark SQL Deep Dive @ Melbourne Spark Meetup by Databricks
Spark SQL Deep Dive @ Melbourne Spark MeetupSpark SQL Deep Dive @ Melbourne Spark Meetup
Spark SQL Deep Dive @ Melbourne Spark Meetup
Databricks9K views
Hadoop and HBase experiences in perf log project by Mao Geng
Hadoop and HBase experiences in perf log projectHadoop and HBase experiences in perf log project
Hadoop and HBase experiences in perf log project
Mao Geng832 views
Virtual training intro to InfluxDB - June 2021 by InfluxData
Virtual training  intro to InfluxDB  - June 2021Virtual training  intro to InfluxDB  - June 2021
Virtual training intro to InfluxDB - June 2021
InfluxData517 views
Introduction to Presto at Treasure Data by Taro L. Saito
Introduction to Presto at Treasure DataIntroduction to Presto at Treasure Data
Introduction to Presto at Treasure Data
Taro L. Saito1.7K views
An Inter-Wiki Page Data Processor for a M2M System @Matsue, 1sep., Eskm2013 by Takashi Yamanoue
An Inter-Wiki Page Data Processor for a M2M System  @Matsue, 1sep., Eskm2013An Inter-Wiki Page Data Processor for a M2M System  @Matsue, 1sep., Eskm2013
An Inter-Wiki Page Data Processor for a M2M System @Matsue, 1sep., Eskm2013
Takashi Yamanoue1.9K views
Eclipse Con Europe 2014 How to use DAWN Science Project by Matthew Gerring
Eclipse Con Europe 2014 How to use DAWN Science ProjectEclipse Con Europe 2014 How to use DAWN Science Project
Eclipse Con Europe 2014 How to use DAWN Science Project
Matthew Gerring37 views

More from InfluxData

Announcing InfluxDB Clustered by
Announcing InfluxDB ClusteredAnnouncing InfluxDB Clustered
Announcing InfluxDB ClusteredInfluxData
101 views30 slides
Best Practices for Leveraging the Apache Arrow Ecosystem by
Best Practices for Leveraging the Apache Arrow EcosystemBest Practices for Leveraging the Apache Arrow Ecosystem
Best Practices for Leveraging the Apache Arrow EcosystemInfluxData
51 views25 slides
How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu... by
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...InfluxData
137 views24 slides
Power Your Predictive Analytics with InfluxDB by
Power Your Predictive Analytics with InfluxDBPower Your Predictive Analytics with InfluxDB
Power Your Predictive Analytics with InfluxDBInfluxData
128 views41 slides
Build an Edge-to-Cloud Solution with the MING Stack by
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 StackInfluxData
381 views52 slides
Meet the Founders: An Open Discussion About Rewriting Using Rust by
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 RustInfluxData
235 views12 slides

More from InfluxData(20)

Announcing InfluxDB Clustered by InfluxData
Announcing InfluxDB ClusteredAnnouncing InfluxDB Clustered
Announcing InfluxDB Clustered
InfluxData101 views
Best Practices for Leveraging the Apache Arrow Ecosystem by InfluxData
Best Practices for Leveraging the Apache Arrow EcosystemBest Practices for Leveraging the Apache Arrow Ecosystem
Best Practices for Leveraging the Apache Arrow Ecosystem
InfluxData51 views
How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu... by InfluxData
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...
InfluxData137 views
Power Your Predictive Analytics with InfluxDB by InfluxData
Power Your Predictive Analytics with InfluxDBPower Your Predictive Analytics with InfluxDB
Power Your Predictive Analytics with InfluxDB
InfluxData128 views
Build an Edge-to-Cloud Solution with the MING Stack by InfluxData
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
InfluxData381 views
Meet the Founders: An Open Discussion About Rewriting Using Rust by InfluxData
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
InfluxData235 views
Introducing InfluxDB Cloud Dedicated by InfluxData
Introducing InfluxDB Cloud DedicatedIntroducing InfluxDB Cloud Dedicated
Introducing InfluxDB Cloud Dedicated
InfluxData129 views
Gain Better Observability with OpenTelemetry and InfluxDB by InfluxData
Gain Better Observability with OpenTelemetry and InfluxDB Gain Better Observability with OpenTelemetry and InfluxDB
Gain Better Observability with OpenTelemetry and InfluxDB
InfluxData403 views
How a Heat Treating Plant Ensures Tight Process Control and Exceptional Quali... by InfluxData
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...
InfluxData184 views
How Delft University's Engineering Students Make Their EV Formula-Style Race ... by 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 ...
InfluxData105 views
Start Automating InfluxDB Deployments at the Edge with balena by InfluxData
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
InfluxData186 views
Understanding InfluxDB’s New Storage Engine by InfluxData
Understanding InfluxDB’s New Storage EngineUnderstanding InfluxDB’s New Storage Engine
Understanding InfluxDB’s New Storage Engine
InfluxData138 views
Streamline and Scale Out Data Pipelines with Kubernetes, Telegraf, and InfluxDB by InfluxData
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
InfluxData63 views
Ward Bowman [PTC] | ThingWorx Long-Term Data Storage with InfluxDB | InfluxDa... by InfluxData
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...
InfluxData74 views
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022 by InfluxData
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
InfluxData26 views
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022 by InfluxData
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
InfluxData9 views
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ... by 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...
InfluxData10 views
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022 by InfluxData
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
InfluxData5 views
Paul Dix [InfluxData] The Journey of InfluxDB | InfluxDays 2022 by InfluxData
Paul Dix [InfluxData] The Journey of InfluxDB | InfluxDays 2022Paul Dix [InfluxData] The Journey of InfluxDB | InfluxDays 2022
Paul Dix [InfluxData] The Journey of InfluxDB | InfluxDays 2022
InfluxData112 views
Jay Clifford [InfluxData] | Tips & Tricks for Analyzing IIoT in Real-Time | I... by InfluxData
Jay Clifford [InfluxData] | Tips & Tricks for Analyzing IIoT in Real-Time | I...Jay Clifford [InfluxData] | Tips & Tricks for Analyzing IIoT in Real-Time | I...
Jay Clifford [InfluxData] | Tips & Tricks for Analyzing IIoT in Real-Time | I...
InfluxData19 views

Recently uploaded

State of the Union - Rohit Yadav - Apache CloudStack by
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStackShapeBlue
218 views53 slides
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
113 views18 slides
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TShapeBlue
81 views34 slides
Data Integrity for Banking and Financial Services by
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial ServicesPrecisely
76 views26 slides
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineShapeBlue
154 views19 slides
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...ShapeBlue
52 views10 slides

Recently uploaded(20)

State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue218 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue113 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue81 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely76 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue154 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue52 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue147 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue134 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software373 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue178 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash103 views
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue59 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue86 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue75 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue114 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue191 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue120 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue172 views

Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux Beginners | InfluxDays Virtual Experience NA 2020

  • 1. Faith Chikwekwe, InfluxData Anais Dotis-Georgiou, InfluxData Top 10 Hurdles for Flux Beginners
  • 3. © 2020 InfluxData. All rights reserved. 3 Introduction to Flux ● Functional query and scripting language ● JavaScript-esque ● Open source ● Written in Go and Flux itself from(bucket:"example-bucket") |> range(start:-1h) |> filter(fn:(r) => r._measurement == "cpu" and r.cpu == "cpu-total" )
  • 4. © 2020 InfluxData. All rights reserved. 4 Introduction to Flux ● Math across Measurements ● Custom Functions ● SPEC and syntax examples available in repo github.com/influxdata/flux/SPEC.md
  • 5. 1.Overlooking UI tools which facilitate writing Flux
  • 6. © 2020 InfluxData. All rights reserved. 6 Using the UI–Solution ● Using the Flux Script Editor ● Using the Raw Data View
  • 7. © 2020 InfluxData. All rights reserved. 7 ● Using the Flux Script Editor ● Variables Using the Flux Builder
  • 8. © 2020 InfluxData. All rights reserved. 8 ● Using the Flux Script Editor ● Variables Injecting Functions
  • 9. © 2020 InfluxData. All rights reserved. 9 Table View vs Raw Data View
  • 10. © 2020 InfluxData. All rights reserved. 10 Using the Raw Data View
  • 11. 2. Folks misunderstand annotated CSVs and sometimes don’t write them correctly.
  • 12. © 2020 InfluxData. All rights reserved. 12 ● array.from() ● to() ● Use github.com/influxdata/flux/stdlib/universe Annotated CSV Solutions
  • 13. © 2020 InfluxData. All rights reserved. 13
  • 14. © 2020 InfluxData. All rights reserved. 14 from(bucket: "cats-and-dogs") |> range(start: 2020-05-15T00:00:00Z, stop: 2020-05-16T00:00:00Z) |> filter(fn: (r) => r["_measurement"] == "cats") |> filter(fn: (r) => r["_field"] == "adult") |> filter(fn: (r) => r["shelter"] == "A") |> filter(fn: (r) => r["type"] == "calico") |> limit(n:2) #group,false,false,true,true,false,false,true,true,true,true #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string #default,_result,,,,,,,,, ,result,table,_start,_stop,_time,_value,_field,_measurement,shelter,type ,,0,2020-05-15T00:00:00Z,2020-05-16T00:00:00Z,2020-05-15T18:50:33.262484Z,8,adult,cats,A,calico ,,0,2020-05-15T00:00:00Z,2020-05-16T00:00:00Z,2020-05-15T18:51:48.852085Z,7,adult,cats,A,calico
  • 15. © 2020 InfluxData. All rights reserved. 15 Explaining Annotated CSV ● #group: A boolean that indicates the column is part of the group key. A group key is a list of columns for which every row in the table has the same value. ○ true columns: In our example query above, we’ve filtered by a single field type, adult, a single “shelter” tag, “A”, and a single “type” tag, “calico”. These values are constant across rows, so those columns are set to true. ○ false columns: The _time and _value columns have different values values across rows which is why they receive a false for the value of the #group Annotation. ● #datatype: Describes the type of data. ● #default: The value to use for rows with an empty value. So for example, if we had assigned our query to the variable ourQuery this annotation would look like: #default,ourQuery,,,,,,,,,
  • 16. © 2020 InfluxData. All rights reserved. 16 import "experimental/array" array.from(rows: [{_measurement: "m0", mytag: "t0", _field: "f0", _value: "foo", _time: 2020-01- 01T00:00:00Z,}, {_measurement: "m0", mytag: "t0", _field: "f0", _value: "bar", _time: 2020-01- 02T00:00:00Z}]) |> to(bucket: “my-bucket”) Using array.from()
  • 17. 3. Data layout design leads to runaway cardinality and slow Flux queries
  • 18. © 2020 InfluxData. All rights reserved. 18 Influx Line Protocol
  • 19. © 2020 InfluxData. All rights reserved. 19 General Recommendations ● Encode meta data in tags. Measurements and tags are indexed while field values are not. Commonly queried metadata should be stored in tags. ● Limit the number of series or try to reduce series cardinality. ● Keep bucket and measurement names short and simple. ● Avoid encoding data in measurement names. ● Separate data into buckets when you need to assign different retention policies to that data or require an authentication token.
  • 20. © 2020 InfluxData. All rights reserved. 20 Common Mistakes Mistake: Making ids (such as eventid, orderid, or userid) a tag. This is another example that can cause unbounded cardinality if the tag values aren’t scoped. Solution: Instead, make these metrics a field.
  • 21. © 2020 InfluxData. All rights reserved. 21 Schema and Flux ● Your schema affects your Flux query performance. ● Anticipate common queries and let that influence your schema design.
  • 22. 4. Storing the wrong data in InfluxDB and under- utilizing Source Functions
  • 23. © 2020 InfluxData. All rights reserved. 23 ● Use Source functions to pull relevant data into InfluxDB as needed ● Work with PostgreSQL, MySQL, Snowflake, SQLite, SQL Server, Athena, BigQuery Source Functions – Solution
  • 24. © 2020 InfluxData. All rights reserved. 24 import "sql" sql.from( driverName: "postgres", dataSourceName: "postgresql://user:password@localhost", query: "SELECT * FROM example_table" ) Source Functions – Solution
  • 25. 5. Confused about how to project multiple aggregations
  • 26. © 2020 InfluxData. All rights reserved. 26 ● Create multiple queries with the UI and visualize them simultaneously ● Get “Fancy” with Flux to project multiple aggregations ○ join() ○ pivot() and union() ○ reduce() Multiple Aggregation Projections – Solutions
  • 27. © 2020 InfluxData. All rights reserved. 27 Multiple Aggregation with the UI
  • 28. © 2020 InfluxData. All rights reserved. 28 data = from(bucket: "my-bucket") |> range(start: 2019-12-31T00:00:00Z, stop: 2020-01-04T00:00:00Z) |> filter(fn: (r) => r._measurement == "my_measurement") |> filter(fn: (r) => r._field == "temp") temp_mean = data |> mean() |> set(key: "agg_type", value: "mean") temp_count = data |> count() |> toFloat() |> set(key: "agg_type", value: "count") union(tables: [temp_mean, temp_count]) |> group(columns: ["agg_type"], mode:"by") |> yield() Union
  • 29. © 2020 InfluxData. All rights reserved. 29 ● The join() function merges two or more input streams, whose values are equal on a set of common columns, into a single output stream. ● The reduce() function aggregates records in each table according to the reducer, fn, providing a way to create custom aggregations. Join and Reduce
  • 30. 6. Common Flux Packages and Utility Functions Not knowing beginner tips to make writing Flux easier
  • 31. © 2020 InfluxData. All rights reserved. 31 Common Flux Packages and Utility Functions aggregateWindow() Create your own utility function to aggregate data for your use case and pass it in as the `fn` param monitor package Write your own check and notification scripts for greater control over alerts `flux/docs/Alerts.md` map() Replace the value in a column (for example offsetting the `_value` column) using the with keyword I need more functionality for my use case Consider contributing a custom package to Flux flux/stdlib/contrib/README.md
  • 32. © 2020 InfluxData. All rights reserved. 32 Custom Aggregate custom_agg = … from(bucket:"items") |> range(start:-1h) |> aggregateWindow(every: 1m, fn: custom_agg) Map from(bucket: “items”) |> filter(fn: (r) => r._measurement == "m") |> map(fn: (r) => ({r with _value: r._value * 2.0} ))
  • 33. © 2020 InfluxData. All rights reserved. 33 Median Absolute Deviation with Flux
  • 34. 7. Performance Gains Being unaware of awesome performance optimizations to make your queries faster in InfluxDB Cloud 2.0
  • 35. © 2020 InfluxData. All rights reserved. 35 - Memory optimizations - More pushdowns - What’s a pushdown? - “Pushing down” the work of transforming the data to be done by the storage side - How does it help optimize my query? Performance Gains
  • 36. © 2020 InfluxData. All rights reserved. 36 Query You have some data stored in InfluxDB Cloud 2.0. You write a query for that data. (e.g. from |> range |> filter |> group |> max) Plan The Flux planner will check if your query matches any existing pushdown patterns. Rewrite If it matches a pushdown pattern, then the planner will write the plan for how to perform your query. Execute The Flux executor will execute your query by invoking a hidden operation (e.g. ReadGroupMax). This will initiate a storage read API call. Result Storage will transform the data and stream the result back to Flux via gRPC. Flux converts the gRPC data back to Flux tables.
  • 37. © 2020 InfluxData. All rights reserved. 37 Assuming your query starts with: - from() |> range() |> filter() [these get pushed down] We’re supporting the following in InfluxDB Cloud 2.0: - Bare aggregates - e.g.|> first() - Windowed aggregates - e.g.|> window() |> first - |> aggregateWindow(first) - Grouped aggregates - e.g. |> group() |> first() - |> group() |> window() |> first() Performance Gains
  • 38. 8. Schema Mutations Not using schema mutators at the right time
  • 39. © 2020 InfluxData. All rights reserved. 39 from(bucket: “itemBucket”) |> range(start: -1mo) |> filter(fn: (r) => (r._measurement == “rate”)) |> filter(fn: (r) => (r._field == “item1”)) |> mean() ... |> drop(columns: [“col1”, “col2”]) keep(), drop(), rename(), duplicate() Schema Mutations
  • 40. 9. Tasks When to write your own tasks
  • 41. © 2020 InfluxData. All rights reserved. 41 How to write a Task
  • 42. © 2020 InfluxData. All rights reserved. 42 option task = {name: “rateTask”, every: 1h} rate = from(bucket: “items”) |> range(start: -task.every) |> filter(fn: (r) => (r._measurement == “totalItems”)) |> filter(fn: (r) => (r._field == “items”)) |> group(columns: [“itemGroupName”]) |> aggregateWindow(fn: sum, every: task.every) |> map(fn: (r) => { return: _time: r._time, _stop: r._stop, _start: r._start, _measurement: “rateTask”, _field: “fruits”, _value: r._value, itemGroupName: itemGroupName, } }) rate |> to(bucket: “newItems”) How to write a Task
  • 43. © 2020 InfluxData. All rights reserved. 43 from(bucket: “newItems”) |> range(start: -1mo) |> filter(fn: (r) => (r._measurement == “rateTask”)) |> filter(fn: (r) => (r._field == “items”)) Output Task Data to a Dashboard Examples for how to write a check and notification script are in flux/doc/Alerts.md. You can even write your own alerts
  • 44. 10. Downsampling Tasks Not knowing when/why to downsample data
  • 45. © 2020 InfluxData. All rights reserved. 45 options task = {name: “foo”, every: 1m} from(bucket: “items”) |> range(start: -task.every) |> filter(fn: r._measurement == "m" and r._field == "f") |> group(columns: ["_measurement", "_field", "_start", "_stop"]) |> aggregateWindow(fn: last, every: task.every) |> to(bucket: "downsample_bucket") Why Downsample?
  • 46. © 2020 InfluxData. All rights reserved. 46 option task = {name: "Downsampling CPU", every: 1m} data = from(bucket: "my-bucket") |> range(start: -task.every) |> filter(fn: (r) => r._measurement == "my_measurement") data |> mean() |> set(key: "agg_type",value: "mean_temp") |> to(bucket: "downsampled", org: "my-org", tagColumns: ["agg_type"]) data |> count() |> set(key: "agg_type",value: “count_temp") |> to(bucket: "downsampled", org: "my-org", tagColumns: ["agg_type"]) Why Downsample?
  • 47. © 2020 InfluxData. All rights reserved. 47 Thanks!