Successfully reported this slideshow.
Your SlideShare is downloading. ×

Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 26 Ad

Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021

Download to read offline

Learn how to get up and running with building a Python application built on the InfluxDB platform. Discover how to connect to InfluxDB from a client library, and best practices for user and data management for your time series application.

Learn how to get up and running with building a Python application built on the InfluxDB platform. Discover how to connect to InfluxDB from a client library, and best practices for user and data management for your time series application.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021 (20)

Advertisement

More from InfluxData (20)

Recently uploaded (20)

Advertisement

Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021

  1. 1. InfluxDB Quickstart Everything you need to know to get started building your application Russ Savage - Product Manager @ Ngrok
  2. 2. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Our Mission An application that is designed to present temperature readings to our users as raw metrics, and also aggregated by minute, hour and day. Our Application
  3. 3. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Cheats Assumptions ● We are focusing on the backend code (not frontend UI) ● We assume Temperature sensors POST JSON messages ● We are ignoring service reliability concerns ● We are ignoring most security concerns ● We are using Python & Flask
  4. 4. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Our Quickstart Application Public Read API Frontend Store and Aggregate Data (InfluxDB) Public Write API
  5. 5. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Write API Requirements ● Single Endpoint for Sensors to POST JSON payloads ○ Transform and forward payload to InfluxDB ● Open Questions ○ What is the InfluxDB Data Model? ○ What format does InfluxDB accept? ○ How do I authenticate with InfluxDB? ○ What’s the easiest way to write data to InfluxDB in Python?
  6. 6. © 2021  InfluxData Inc. All Rights Reserved.
  7. 7. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. InfluxDB Quickstart Glossary ● Organization - A workspace for a group of users ● Bucket - Combines the concept of a database and a retention period (the duration of time that each data point persists) ● Measurement - A name to a group of data at a high level ● Tag set - A set of key-value pairs to group data at a low level (values are strings) ● Field set - A set of key-value pairs to represent data (values are numerical & strings) ● Series - A unique combination of measurement + tags
  8. 8. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Line Protocol ● All data must be converted into Line Protocol before being sent to the InfluxDB write API. ● Line Protocol follows the following format: https:/ /docs.influxdata.com/influxdb/cloud/reference/syntax/line-protocol/ Tag Set hostname=server02, us_west=az Measurement cpu_load Field Set temp=24.5, volts=7 Timestamp 1234567890000000
  9. 9. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● API Tokens are needed for any 3rd party system to access InfluxDB data or resources. ● API Tokens are owned by a user, and can have read/write permissions for each Bucket. ● Your first token MUST be created through the web interface. https:/ /docs.influxdata.com/influxdb/cloud/security/tokens InfluxDB API Tokens
  10. 10. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● InfluxDB provides client libraries for common languages to incorporate into your code and use the API easily. InfluxDB Client Libraries
  11. 11. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● Use the Point object included in every Client Library to convert your data to Line Protocol. Mapping Data to Line Protocol
  12. 12. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● Find all this information in the Client Library examples: ○ URL ○ Org ○ Token ○ Bucket Get Your Connection Details from InfluxDB
  13. 13. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Example Write API Code
  14. 14. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Where are we? Public Read API Frontend Store and Aggregate Data (InfluxDB) Public Write API
  15. 15. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Read API Requirements ● Single endpoint to GET temperature data ○ Query from InfluxDB and provide results as JSON ● Open questions ○ How do we get data out of InfluxDB?
  16. 16. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● Flux queries are the way to extract data from InfluxDB. ● Quickstart Flux Functions ○ from ○ range ○ filter ○ aggregateWindow https:/ /docs.influxdata.com/flux/v0.x/ Flux: Powerful Data Scripting Language
  17. 17. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Example Read API Code
  18. 18. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Where are we? Public Read API Frontend Store and Aggregate Data (InfluxDB) Public Write API
  19. 19. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● Flux is all about functions, so just add one ● Poor performance since the calculation is run on every query Wait, what about aggregations?
  20. 20. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● Run Flux queries on a schedule, store results for faster access. ● More Flux Functions: ○ map - change the columns of values of each row ○ to - write data back to InfluxDB InfluxDB Tasks: Create and store custom metrics
  21. 21. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. InfluxDB Tasks: Create and store custom metrics
  22. 22. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. InfluxDB Tasks: Create and store custom metrics
  23. 23. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Updated Read API Code • Aggregation done once on the server instead of for each API request
  24. 24. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Where are we? Public Read API Frontend Store and Aggregate Data (InfluxDB) Public Write API
  25. 25. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. ● If you use VSCode, load the Flux VSCode plugin ○ Easily test and debug Flux code in your IDE ● Influx CLI ○ Quickly manage and automate against the InfluxDB APIs ● InfluxDB Templates / Stacks ○ GitOps workflows built into the platform for CI/CD ● Advanced Flux ○ Transform as much as you can in Flux to keep your client code simple ● InfluxDB API Invocable Scripts ○ Your Flux Script is now an API your code can call What’s Next?
  26. 26. © 2021  InfluxData Inc. All Rights Reserved. Thank you! russ@ngrok.com GitHub: russorat

×