SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
Katy Farmer
Developer Advocate
@thekatertot
Using the SQL
Datasource in 2.0
InfluxDB . + Flux + SQL (+ you!)
Multiple Datasources
InfluxDB . + Flux + SQL (+ you!)
Multiple Datasources
Why?
• Connect your time series data
with other types of data for
enrichment (and for fun)
• Single responsibility databases
Why?
• Connect your time series data
with other types of data for
enrichment (and for fun)
• Single responsibility databases
© InfluxData. All rights reserved.
Industrial IoT
Relational Data
All sensor metrics (temperature, pressure,
water level,
Time Series Data
Hardware information (model, year, etc.), date
deployed, region, id
© InfluxData. All rights reserved.
Industrial IoT
Relational Data
All sensor metrics (temperature, pressure,
water level,
Time Series Data
Hardware information (model, year, etc.), date
deployed, region, id
© InfluxData. All rights reserved.
Industrial IoT
Relational Data
All sensor metrics (temperature, pressure,
water level,
Time Series Data
Hardware information (model, year, etc.), date
deployed, region, id
© InfluxData. All rights reserved.
User Tracking
Relational Data
Logins, page visits, clicks, duration on page
Time Series Data
Name, email, location, history (browsing,
purchases, etc.)
© InfluxData. All rights reserved.
User Tracking
Relational Data
Logins, page visits, clicks, duration on page
Time Series Data
Name, email, location, history (browsing,
purchases, etc.)
© InfluxData. All rights reserved.
User Tracking
Relational Data
Logins, page visits, clicks, duration on page
Time Series Data
Name, email, location, history (browsing,
purchases, etc.)
Example:
Robots
(Industrial IoT)
Each robot has:
❏ ID
❏ name
❏ model
❏ created_at (timestamp)
Example:
Robots
(Industrial IoT)
Each robot has:
❏ ID
❏ name
❏ model
❏ created_at (timestamp)
Example:
Robots
(Industrial IoT)
Each robot has:
❏ ID
❏ name
❏ model
❏ created_at (timestamp)
Example:
Robots
(Industrial IoT)
Each robot has:
❏ ID
❏ name
❏ model
❏ created_at (timestamp)
Example:
Robots
(Industrial IoT)
Robot jobs vary. Some measure parts, some
place parts on belts, and others rotate the
parts for inspection. But not all robots
perform the same. Some of them crash.
What is the average CPU usage of each
robot?
Example:
Robots
(Industrial IoT)
Robot jobs vary. Some measure parts, some
place parts on belts, and others rotate the
parts for inspection. But not all robots
perform the same. Some of them crash.
What is the average CPU usage of each
robot?
Example:
Robots
(Industrial IoT)
Robot jobs vary. Some measure parts, some
place parts on belts, and others rotate the
parts for inspection. But not all robots
perform the same. Some of them crash.
What is the average CPU usage of each
robot?
© InfluxData. All rights reserved.
Step : Importing SQL Data with Flux
import "sql"
sql.from(
driverName: "postgres",
dataSourceName: "postgresql://user:password@localhost",
query:"SELECT * FROM mydb;")
© InfluxData. All rights reserved.
Step : Importing SQL Data with Flux
import "sql"
sql.from(
driverName: "postgres",
dataSourceName:
"postgresql://localhost/robots?sslmode=disable",
query:"SELECT * FROM robots;")
© InfluxData. All rights reserved.© InfluxData. All rights reserved.
© InfluxData. All rights reserved.
Step : Write your first Flux query
from(bucket: "robots")
|> range(start: -10d)
|> filter(fn: (r) => r._measurement == "cpu")
|> filter(fn: (r) => r._field == "system_usage")
|> mean()
© InfluxData. All rights reserved.© InfluxData. All rights reserved.
© InfluxData. All rights reserved.
Step : Joining Data Streams
import "sql"
info = sql.from(
driverName: "postgres",
dataSourceName: "postgresql://localhost/robots?sslmode=disable",
query:"SELECT * FROM robots;")
cpu = from(bucket: "robots")
|> range(start: -10d)
|> filter(fn: (r) => r._measurement == "cpu")
|> filter(fn: (r) => r._field == "system_usage")
|> mean()
join(tables: {cpu:cpu, info:info}, on: ["id"])
© InfluxData. All rights reserved.© InfluxData. All rights reserved.
© InfluxData. All rights reserved.
Step : Storing Results
sql.to() requirements:
❏ Data in the stream must have same column names as the
SQL DB
❏ Drop any columns that won’t be stored
❏ Remember your schema! Any rules (not null, unique, etc.)
must be followed or the write will not succeed.
© InfluxData. All rights reserved.
import "sql"
info = sql.from(
driverName: "postgres",
dataSourceName: "postgresql://localhost/robots?sslmode=disable",
query:"SELECT * FROM robots;")
cpu = from(bucket: "robots")
|> range(start: -10d)
|> filter(fn: (r) => r._measurement == "cpu")
|> filter(fn: (r) => r._field == "system_usage")
|> mean()
join(tables: {cpu:cpu, info:info}, on: ["id"])
|> keep(columns: ["id", "_value", "created_at"])
|> sql.to(
driverName: "postgres",
dataSourceName: "postgresql://localhost/robots?sslmode=disable",
table: "averages")
© InfluxData. All rights reserved.
Things I did wrong
© InfluxData. All rights reserved.
Things I did wrong
© InfluxData. All rights reserved.
Questions
Thank you!
katy@influxdata.com
@thekatertot
© InfluxData. All rights reserved.
Questions
Thank you!
katy@influxdata.com
@thekatertot
© InfluxData. All rights reserved.
Questions
Thank you!
katy@influxdata.com
@thekatertot
© InfluxData. All rights reserved.
Questions
Thank you!
katy@influxdata.com
@thekatertot
© InfluxData. All rights reserved.
Questions
Thank you!
katy@influxdata.com
@thekatertot

Contenu connexe

Tendances

Tendances (20)

Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
 
Advanced kapacitor
Advanced kapacitorAdvanced kapacitor
Advanced kapacitor
 
Observability of InfluxDB IOx: Tracing, Metrics and System Tables
Observability of InfluxDB IOx: Tracing, Metrics and System TablesObservability of InfluxDB IOx: Tracing, Metrics and System Tables
Observability of InfluxDB IOx: Tracing, Metrics and System Tables
 
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...
Extending Flux to Support Other Databases and Data Stores | Adam Anthony | In...
 
Introduction to Flux and Functional Data Scripting
Introduction to Flux and Functional Data ScriptingIntroduction to Flux and Functional Data Scripting
Introduction to Flux and Functional Data Scripting
 
Virtual training Intro to Kapacitor
Virtual training  Intro to Kapacitor Virtual training  Intro to Kapacitor
Virtual training Intro to Kapacitor
 
How to Build a Telegraf Plugin by Noah Crowley
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
 
Catalogs - Turning a Set of Parquet Files into a Data Set
Catalogs - Turning a Set of Parquet Files into a Data SetCatalogs - Turning a Set of Parquet Files into a Data Set
Catalogs - Turning a Set of Parquet Files into a Data Set
 
OPTIMIZING THE TICK STACK
OPTIMIZING THE TICK STACKOPTIMIZING THE TICK STACK
OPTIMIZING THE TICK STACK
 
WRITING QUERIES (INFLUXQL AND TICK)
WRITING QUERIES (INFLUXQL AND TICK)WRITING QUERIES (INFLUXQL AND TICK)
WRITING QUERIES (INFLUXQL AND TICK)
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
 
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
 
Setting up InfluxData for IoT
Setting up InfluxData for IoTSetting up InfluxData for IoT
Setting up InfluxData for IoT
 
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 |...
InfluxDB 101 – Concepts and Architecture by Michael DeSa, Software Engineer |...
 
Virtual training Intro to InfluxDB & Telegraf
Virtual training  Intro to InfluxDB & TelegrafVirtual training  Intro to InfluxDB & Telegraf
Virtual training Intro to InfluxDB & Telegraf
 
Intro to Kapacitor for Alerting and Anomaly Detection
Intro to Kapacitor for Alerting and Anomaly DetectionIntro to Kapacitor for Alerting and Anomaly Detection
Intro to Kapacitor for Alerting and Anomaly Detection
 
Write your own telegraf plugin
Write your own telegraf pluginWrite your own telegraf plugin
Write your own telegraf plugin
 
Introduction to InfluxDB
Introduction to InfluxDBIntroduction to InfluxDB
Introduction to InfluxDB
 
InfluxData Architecture for IoT | Noah Crowley | InfluxData
InfluxData Architecture for IoT | Noah Crowley | InfluxDataInfluxData Architecture for IoT | Noah Crowley | InfluxData
InfluxData Architecture for IoT | Noah Crowley | InfluxData
 
Kapacitor Stream Processing
Kapacitor Stream ProcessingKapacitor Stream Processing
Kapacitor Stream Processing
 

Similaire à Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData

Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Tom Diederich
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
jucaab
 

Similaire à Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData (20)

Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data center
 
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB StitchMongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
 
Rsockets ofa12
Rsockets ofa12Rsockets ofa12
Rsockets ofa12
 
Cloud Computing for Business - The Road to IT-as-a-Service
Cloud Computing for Business - The Road to IT-as-a-ServiceCloud Computing for Business - The Road to IT-as-a-Service
Cloud Computing for Business - The Road to IT-as-a-Service
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data Analytics
 
Azure Stream Analytics : Analyse Data in Motion
Azure Stream Analytics  : Analyse Data in MotionAzure Stream Analytics  : Analyse Data in Motion
Azure Stream Analytics : Analyse Data in Motion
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
 
2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server
 
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
 
Serverless and IoT
Serverless and IoTServerless and IoT
Serverless and IoT
 
Metaverse and Digital Twins on Enterprise-Public.pdf
Metaverse and Digital Twins on Enterprise-Public.pdfMetaverse and Digital Twins on Enterprise-Public.pdf
Metaverse and Digital Twins on Enterprise-Public.pdf
 
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
 
Discrete MFG IoT Factory of the Future
Discrete MFG IoT Factory of the FutureDiscrete MFG IoT Factory of the Future
Discrete MFG IoT Factory of the Future
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
IoT
IoT IoT
IoT
 
Power Your Predictive Analytics with InfluxDB
Power Your Predictive Analytics with InfluxDBPower Your Predictive Analytics with InfluxDB
Power Your Predictive Analytics with InfluxDB
 
What's New in Apache Hive
What's New in Apache HiveWhat's New in Apache Hive
What's New in Apache Hive
 
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
 

Plus de InfluxData

How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
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 ...
How Delft University's Engineering Students Make Their EV Formula-Style Race ...
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...
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
InfluxData
 
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
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
InfluxData
 
Paul Dix [InfluxData] The Journey of InfluxDB | InfluxDays 2022
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
InfluxData
 

Plus de InfluxData (20)

Announcing InfluxDB Clustered
Announcing InfluxDB ClusteredAnnouncing InfluxDB Clustered
Announcing InfluxDB Clustered
 
Best Practices for Leveraging the Apache Arrow Ecosystem
Best Practices for Leveraging the Apache Arrow EcosystemBest Practices for Leveraging the Apache Arrow Ecosystem
Best Practices for Leveraging the Apache Arrow Ecosystem
 
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...
How Bevi Uses InfluxDB and Grafana to Improve Predictive Maintenance and Redu...
 
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
How Teréga Replaces Legacy Data Historians with InfluxDB, AWS and IO-Base
 
Build an Edge-to-Cloud Solution with the MING Stack
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
 
Meet the Founders: An Open Discussion About Rewriting Using Rust
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
 
Introducing InfluxDB Cloud Dedicated
Introducing InfluxDB Cloud DedicatedIntroducing InfluxDB Cloud Dedicated
Introducing InfluxDB Cloud Dedicated
 
Gain Better Observability with OpenTelemetry and InfluxDB
Gain Better Observability with OpenTelemetry and InfluxDB Gain Better Observability with OpenTelemetry and InfluxDB
Gain Better Observability with OpenTelemetry and InfluxDB
 
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...
How a Heat Treating Plant Ensures Tight Process Control and Exceptional Quali...
 
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 ...
How Delft University's Engineering Students Make Their EV Formula-Style Race ...
 
Introducing InfluxDB’s New Time Series Database Storage Engine
Introducing InfluxDB’s New Time Series Database Storage EngineIntroducing InfluxDB’s New Time Series Database Storage Engine
Introducing InfluxDB’s New Time Series Database Storage Engine
 
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
Start Automating InfluxDB Deployments at the Edge with balena
 
Understanding InfluxDB’s New Storage Engine
Understanding InfluxDB’s New Storage EngineUnderstanding InfluxDB’s New Storage Engine
Understanding InfluxDB’s New Storage Engine
 
Streamline and Scale Out Data Pipelines with Kubernetes, Telegraf, and InfluxDB
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
 
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...
Ward Bowman [PTC] | ThingWorx Long-Term Data Storage with InfluxDB | InfluxDa...
 
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
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
 
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
Steinkamp, Clifford [InfluxData] | Closing Thoughts | InfluxDays 2022
 
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...
Steinkamp, Clifford [InfluxData] | Welcome to InfluxDays 2022 - Day 2 | Influ...
 
Steinkamp, Clifford [InfluxData] | Closing Thoughts Day 1 | InfluxDays 2022
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
 
Paul Dix [InfluxData] The Journey of InfluxDB | InfluxDays 2022
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
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData

  • 2. InfluxDB . + Flux + SQL (+ you!) Multiple Datasources InfluxDB . + Flux + SQL (+ you!) Multiple Datasources
  • 3. Why? • Connect your time series data with other types of data for enrichment (and for fun) • Single responsibility databases Why? • Connect your time series data with other types of data for enrichment (and for fun) • Single responsibility databases
  • 4. © InfluxData. All rights reserved. Industrial IoT Relational Data All sensor metrics (temperature, pressure, water level, Time Series Data Hardware information (model, year, etc.), date deployed, region, id © InfluxData. All rights reserved. Industrial IoT Relational Data All sensor metrics (temperature, pressure, water level, Time Series Data Hardware information (model, year, etc.), date deployed, region, id © InfluxData. All rights reserved. Industrial IoT Relational Data All sensor metrics (temperature, pressure, water level, Time Series Data Hardware information (model, year, etc.), date deployed, region, id
  • 5. © InfluxData. All rights reserved. User Tracking Relational Data Logins, page visits, clicks, duration on page Time Series Data Name, email, location, history (browsing, purchases, etc.) © InfluxData. All rights reserved. User Tracking Relational Data Logins, page visits, clicks, duration on page Time Series Data Name, email, location, history (browsing, purchases, etc.) © InfluxData. All rights reserved. User Tracking Relational Data Logins, page visits, clicks, duration on page Time Series Data Name, email, location, history (browsing, purchases, etc.)
  • 6. Example: Robots (Industrial IoT) Each robot has: ❏ ID ❏ name ❏ model ❏ created_at (timestamp) Example: Robots (Industrial IoT) Each robot has: ❏ ID ❏ name ❏ model ❏ created_at (timestamp) Example: Robots (Industrial IoT) Each robot has: ❏ ID ❏ name ❏ model ❏ created_at (timestamp) Example: Robots (Industrial IoT) Each robot has: ❏ ID ❏ name ❏ model ❏ created_at (timestamp)
  • 7. Example: Robots (Industrial IoT) Robot jobs vary. Some measure parts, some place parts on belts, and others rotate the parts for inspection. But not all robots perform the same. Some of them crash. What is the average CPU usage of each robot? Example: Robots (Industrial IoT) Robot jobs vary. Some measure parts, some place parts on belts, and others rotate the parts for inspection. But not all robots perform the same. Some of them crash. What is the average CPU usage of each robot? Example: Robots (Industrial IoT) Robot jobs vary. Some measure parts, some place parts on belts, and others rotate the parts for inspection. But not all robots perform the same. Some of them crash. What is the average CPU usage of each robot?
  • 8. © InfluxData. All rights reserved. Step : Importing SQL Data with Flux import "sql" sql.from( driverName: "postgres", dataSourceName: "postgresql://user:password@localhost", query:"SELECT * FROM mydb;")
  • 9. © InfluxData. All rights reserved. Step : Importing SQL Data with Flux import "sql" sql.from( driverName: "postgres", dataSourceName: "postgresql://localhost/robots?sslmode=disable", query:"SELECT * FROM robots;")
  • 10. © InfluxData. All rights reserved.© InfluxData. All rights reserved.
  • 11. © InfluxData. All rights reserved. Step : Write your first Flux query from(bucket: "robots") |> range(start: -10d) |> filter(fn: (r) => r._measurement == "cpu") |> filter(fn: (r) => r._field == "system_usage") |> mean()
  • 12. © InfluxData. All rights reserved.© InfluxData. All rights reserved.
  • 13. © InfluxData. All rights reserved. Step : Joining Data Streams import "sql" info = sql.from( driverName: "postgres", dataSourceName: "postgresql://localhost/robots?sslmode=disable", query:"SELECT * FROM robots;") cpu = from(bucket: "robots") |> range(start: -10d) |> filter(fn: (r) => r._measurement == "cpu") |> filter(fn: (r) => r._field == "system_usage") |> mean() join(tables: {cpu:cpu, info:info}, on: ["id"])
  • 14. © InfluxData. All rights reserved.© InfluxData. All rights reserved.
  • 15. © InfluxData. All rights reserved. Step : Storing Results sql.to() requirements: ❏ Data in the stream must have same column names as the SQL DB ❏ Drop any columns that won’t be stored ❏ Remember your schema! Any rules (not null, unique, etc.) must be followed or the write will not succeed.
  • 16. © InfluxData. All rights reserved. import "sql" info = sql.from( driverName: "postgres", dataSourceName: "postgresql://localhost/robots?sslmode=disable", query:"SELECT * FROM robots;") cpu = from(bucket: "robots") |> range(start: -10d) |> filter(fn: (r) => r._measurement == "cpu") |> filter(fn: (r) => r._field == "system_usage") |> mean() join(tables: {cpu:cpu, info:info}, on: ["id"]) |> keep(columns: ["id", "_value", "created_at"]) |> sql.to( driverName: "postgres", dataSourceName: "postgresql://localhost/robots?sslmode=disable", table: "averages")
  • 17. © InfluxData. All rights reserved. Things I did wrong © InfluxData. All rights reserved. Things I did wrong
  • 18. © InfluxData. All rights reserved. Questions Thank you! katy@influxdata.com @thekatertot © InfluxData. All rights reserved. Questions Thank you! katy@influxdata.com @thekatertot © InfluxData. All rights reserved. Questions Thank you! katy@influxdata.com @thekatertot © InfluxData. All rights reserved. Questions Thank you! katy@influxdata.com @thekatertot © InfluxData. All rights reserved. Questions Thank you! katy@influxdata.com @thekatertot