Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi

1,073 views

Published on

Flux, the new InfluxData data scripting and query language (formerly IFQL), super-charges queries both for analytics and data science. Jacob Lisi from Grafana Labs will give a quick overview of the language features as well as the moving parts for a working deployment. Grafana is an open source dashboard solution that shares Flux’s passion for analytics and data science. For that reason, they are very excited to showcase the new Flux support within Grafana, and a couple of common analytics use cases to get the most out of your data.

In this InfluxDays NYC 2019 talk, Jacob Lisi will share the latest updates they have made with their Flux builder in Grafana.

  • Login to see the comments

Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi

  1. 1. Grafana & Flux New Flux support in Grafana Jacob Lisi @JacobLisi
  2. 2. TL;DR ● Flux is powerful ● You can start playing with Flux in Grafana today ○ Flux support in Grafana is available via a new datasource plugin ● For now, no automated way to migrate dashboards ○ Transpiler for Influx queries is being worked on ○ You can migrate your dashboards and panels manually
  3. 3. Flux Design Goals ● Decouple language from the execution engine ○ Execution engine takes a DAG of transformations ○ Transpilers: Flux, Influx Query, PromQL ● Decouple database from query computation ○ Iterate faster on query engine ○ Keep database untouched ○ Independently scalable ● Add more functions ○ Chainable: transformation from input table to output table
  4. 4. Flux recap from(db: “telegraf”) |> filter(fn: (r) => r[“host”] == “myServer”) |> range(start: -1h)
  5. 5. Flux recap: Select one value from a table from(db: “telegraf”) |> filter(fn: (r) => r[“host”] == “myServer”) |> range(start: -1h) |> max() // Selector
  6. 6. Flux primer: Window-chunk and aggregate from(db: “telegraf”) |> filter(fn: (r) => r[“_measurement”] == “cpu”) |> range(start: -1h) |> window(every: 10m) |> mean() // Aggregator |> filter(fn: (r) => r._value > 1) // Having
  7. 7. Flux query planning from(db: “telegraf”) |> filter(fn: (r) => r[“host”] == “myServer”) |> range(start: -1h) |> max() from(db: “telegraf”) |> range(start: -1h) |> filter(fn: (r) => r[“host”] == “myServer”) |> max() ● Same plan DAG
  8. 8. Flux query planning gotchas from(db: “telegraf”) |> filter(fn: (r) => r[“host”] == “myServer”) |> range(start: -1h) |> max() from(db: “telegraf”) |> filter(fn: (r) => r[“host”] == “myServer”) |> max() // Selector function returns 1 record |> range(start: -1h) from(db: “telegraf”) |> range(start: -1h) |> filter(fn: (r) => r[“_value”] > 1) // Full table scan
  9. 9. User defined functions select = (db=”telegraf”, m, f) => { return from(db:db) |> filter(fn: (r) => r._measurement == m and r._field == f) } select(m: “cpu”, f: “usage_user”) |> filter(fn: (r) => r[“host”] == “myServer”) |> range(start: -1h)
  10. 10. Chainable user defined functions myFilter = (m, f, table=<-) => { return table |> filter(fn: (r) => r._measurement == m and r._field == f) } from(db: “telegraf”) |> myFilter(m: “cpu”, f: “usage_user”) |> range(start: -1h)
  11. 11. Flux StdLib https://github.com/influxdata/flux/tree/master/stdlib
  12. 12. Math on tables cpu = from(db)... CpuRequests = from(db)... join( tables: {cpu: cpu, req: CpuRequests}, fn: (t) => t.cpu._value / t.req._value ) // Implicit join on time
  13. 13. New response format: CSV
  14. 14. Getting Started With Flux ● Run latest influxd ○ https://portal.influxdata.com/downloads ○ Update your influxdb.conf to include ● Generate data ○ Telegraf # ... [http] # ... flux-enabled = true # ...
  15. 15. Get started: Grafana datasource ● Get Grafana 5.3+ ● Install Flux datasource plugin ○ https://github.com/grafana/influxdb-flux-datasource ○ Clone into your grafanas data/plugins ○ Restart Grafana ● Add your Flux datasource ● Add a dashboard ● Add a panel
  16. 16. Demo https://github.com/jtlisi/grafana_flux_demo
  17. 17. Datasource feature summary ● Syntax highlighting, tab completion, raw table preview ● Inline function documentation ● $range variable
  18. 18. Datasource feature summary ● Shortcodes ● Template variables with helper functions ○ measurements() ○ field_keys() ○ tags() ○ tag_values() ● Annotations
  19. 19. Roadmap ● Alerting ● UI improvements ● Improve Query Shortcuts ● Transitioning to a default plugin ● Dashboard Migrations?
  20. 20. Thanks for listening! Questions? @JacobLisi

×