Hurdle 1: Unaware of common Flux Packages and Utility Functions

Solution 1: Some important Flux tips and Flux utilities to make writing Flux easier

|> range(start:-1h)
|> aggregateWindow(every: 1m, fn: mean())
multByX = (x) => (column, tables=<-) =>  tables  
|> mean(column:column)
|> map(fn: (r) => ({ r with _value: r._value * x}))
from(bucket: "my-bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "cpu")
|> filter(fn: (r) => r["_field"] == "usage_system")
|> limit(n: 10)
|> aggregateWindow(every: v.windowPeriod, fn: multByX(x:2.0))

Hurdle 2: Unaware of performance gains that make your query faster

Solution 2: Learning about memory optimizations and new pushdown patterns to optimize your Flux scripts

  • |> count()
  • |> sum()
  • |> first()
  • |> last()
  • |> min()
  • |> max()
  • |> mean()
  • |>group() |> count()
  • |>group() |> sum()
  • …etc.
  • |>window() |> count()
  • |>window() |> sum()
  • …etc.
  • |>aggregateWindow(fn: count)
  • |>aggregateWindow(fn: sum)
  • …etc.

Hurdle 3: Using schema mutation functions at the wrong time

Solution 3: Learn when to apply schema mutations

Hurdle 4: Unsure about task writing best practices

Solution 4: Task writing recommendations.

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:, newTag: “rate”, _value: r._value, itemGroupName: itemGroupName,
|> to(bucket: “newItems”)
from(bucket: “neItems”)
|> range(start: -task.every)
|> filter(fn: (r) => (r._measurement == “rateTask”)
|> filter(fn: (r) => (r.newTag == “rate”)
option task = {name: "Downsampling CPU", every: 1m}data = from(bucket: "my-bucket")
|> range(start: -task.every)
|> filter(fn: (r) => r._measurement == "my_measurement")
|> mean()
|> set(key: "agg_type",value: "mean_temp")
|> to(bucket: "downsampled", org: "my-org", tagColumns: ["agg_type"])
|> count()
|> set(key: "agg_type",value: “count_temp")
|> to(bucket: "downsampled", org: "my-org", tagColumns: ["agg_type"])

Hurdle 5: Unsure about when to write a downsampling task

Solution 5: Learn about when to write a downsampling task

Next steps for tacking hurdles for intermediate Flux users




Developer Advocate at InfluxData

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Set Up a Firewall Using FirewallD on CentOS 7

Why I choose freeCodeCamp!!

Slow Agile — Part Two: the Psychology of Numbers

Linux Basic Commands

Finding The Most Important Sentences Using TF-IDF by Python

Playing With KMS Key Policies

Ansible and hadoop!

Saving gas with Propane tools

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anais Dotis

Anais Dotis

Developer Advocate at InfluxData

More from Medium

How Orbitron Works

“Static” and runtime type checking for python dict at same time

How Docker eased up my life?

How to run and debug Apache Superset using Pycharm or IntelliJ