Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Using Telegraf and Flux | InfluxDays Virtual Experience NA 2020

InfluxData
InfluxDataInfluxData
Samantha Wang
Product Manager, InfluxData
Best Practices on How
to Transform Your
Data Using Telegraf
and Flux
© 2020 InfluxData. All rights reserved. 2
Why do we transform data?
Problems:
● Resource-intensive.
● Lack of expertise and carelessness
● Better-organization
● Facilitates compatibility between applications, systems,
and types of data
© 2020 InfluxData. All rights reserved. 3
Goals:
1. How to transform your data to fit the optimal state of your
monitoring environment
2. Tools for transformation BEFORE data ingestion
a. The power of Telegraf processors and aggregators
3. Tools for transformation AFTER data ingestion
a. The power of Flux transformation queries
Basic data Concepts of
InfluxDB
© 2020 InfluxData. All rights reserved. 5
What you’re
collecting
Data
ingestion
Database!!
Visualizations
Analytics
transform!
transform!
© 2020 InfluxData. All rights reserved. 6
© 2020 InfluxData. All rights reserved. 7
weather,location=us-midwest temperature=82,humidity=71 1465839830100400200
InfluxDB Line Protocol
tag(s) field(s) timestamp
weather location=us-midwest temperature=82,humidity=71
BEFORE load:
Transforming data with
Telegraf
© 2020 InfluxData. All rights reserved. 9
Telegraf
CPU
Mem
Disk
Docker
Kubernetes
/metrics
Kafka
MySQL
Process
- transform
- decorate
- filter
Aggregate
- mean
- min,max
- count
- variance
- stddev
InfluxDB
File
Kafka
CloudWatch
CloudWatch
Input Output
© 2020 InfluxData. All rights reserved. 10
Why manipulate data with Telegraf?
● Convert tags ↔ fields or data types
● Rename field names or values
● Aggregate data
● Clean up or filter data
● Perform data transformation as close to the device
● Improve performance
© 2020 InfluxData. All rights reserved. 11
Convert Data:
[[processors.converter]]
[processors.converter.tags]
measurement = []
string = []
integer = []
unsigned = []
boolean = []
float = []
[processors.converter.fields]
measurement = []
tag = []
string = []
processors.converter
© 2020 InfluxData. All rights reserved. 12
Convert tags ↔ fields
Convert port tag to a string field:
[[processors.converter]]
[processors.converter.tags]
string = ["port"]
- apache,port=80,server=debian-stretch-apache BytesPerReq=0
+ apache,server=debian-stretch-apache port="80",BytesPerReq=0
[[processors.converter]]
[processors.converter.fields]
tag = ["port"]
- apache,server=debian-stretch-apache port="80",BytesPerReq=0
+ apache,port=80,server=debian-stretch-apache BytesPerReq=0
Convert port field to a tag:
© 2020 InfluxData. All rights reserved. 13
Convert data types
Convert all scboard_* fields to
an integer: [[processors.converter]]
[processors.converter.fields]
integer = ["scboard_*"]
- apache scboard_open=100,scboard_reading=0,scboard_sending=1,scboard_starting=0,scboard_waiting=49
+ apache scboard_open=100i,scboard_reading=0i,scboard_sending=1i,scboard_starting=0i,scboard_waiting=49i
© 2020 InfluxData. All rights reserved. 14
Mapping:
[[processors.enum]]
[[processors.enum.mapping]]
tag = "StorageType"
dest = "StorageName"
[processors.enum.mapping.value_mappings]
".1.3.6.1.2.1.25.2.1.1" = "Other"
".1.3.6.1.2.1.25.2.1.2" = "RAM"
".1.3.6.1.2.1.25.2.1.3" = "Virtual Memory"
".1.3.6.1.2.1.25.2.1.4" = "Fixed Disk"
".1.3.6.1.2.1.25.2.1.5" = "Removable Disk"
".1.3.6.1.2.1.25.2.1.6" = "Floppy Disk"
".1.3.6.1.2.1.25.2.1.7" = "Compact Disc"
".1.3.6.1.2.1.25.2.1.8" = "RAM Disk"
- snmp StorageType=".1.3.6.1.2.1.25.2.1.6" 1502489900000000000
+ snmp StorageName="Floppy Disk",StorageType=".1.3.6.1.2.1.25.2.1.6" 1502489900000000000
Enum Processor:
● value mappings for metric tags
or fields
● Common use case is to map
status codes
processors.enum
© 2020 InfluxData. All rights reserved. 15
Transform tags and fields:
Regex Processor:
● Change tags and manipulate field values with regex patterns
● Can replace existing field OR produce new tags and fields
while maintaining existing ones
processors.regex
© 2020 InfluxData. All rights reserved. 16
- nginx,resp_code=200 request="/api/search/?category=plugins&q=regex&sort=asc",referrer="-",ident="-
",http_version=1.1,client_ip="127.0.0.1" 1519652321000000000
+ nginx,resp_code=2xx
request="/api/search/?category=plugins&q=regex&sort=asc",method="/search/",search_category="p
lugins",referrer="-",ident="-",http_version=1.1,client_ip="127.0.0.1" 1519652321000000000
[[processors.regex]]
namepass = ["nginx"]
[[processors.regex.tags]]
key = "resp_code"
pattern = "^(d)dd$"
replacement = "${1}xx"
[[processors.regex.fields]]
key = "request"
pattern = "^/api(?P<method>/[w/]+)S*"
replacement = "${method}"
result_key = "method"
[[processors.regex.fields]]
key = "request"
pattern = ".*category=(w+).*"
replacement = "${1}"
result_key = "search_category"
© 2020 InfluxData. All rights reserved. 17
Math & Logic Operations:
● Dialect of Python
● Starlark specification
(google/starlark-go) has details
about the syntax and available
functions
● Use Cases:
○ Math operations
○ Logic operations
○ Some string operations
○ Add or remove
tags/fields/metrics
[[processors.starlark]]
## Source of the Starlark script.
source = '''
def apply(metric):
return metric
'''
## File containing a Starlark
script.
# script =
"/usr/local/bin/myscript.star"
processors.starlark
© 2020 InfluxData. All rights reserved. 18
Basic Math - IoT
Example w/ Modbus Plugin:
Calculate power from voltage
& current
P = I * V
[[processors.starlark]]
source = '''
def apply(metric):
I = metric.fields['current']
V = metric.fields['voltage']
metric.fields['power'] = I * V
return metric
'''
- modbus.InputRegisters,host=localhost current=550,frequency=60,voltage=12.93223 1554079521000000000
+ modbus.InputRegisters,host=localhost current=550,frequency=60,voltage=12.93223,power=7112.7265 1554079521000000000
© 2020 InfluxData. All rights reserved. 19
Other useful transformations
Clone - creates a copy of each metric to preserve the original metric and allow modifications in the
copied metric
Date - adds the metric timestamp as a human readable tag
Dedup - filters metrics whose field values are exact repetitions of the previous values.
Ifname - processor plugin looks up network interface names using SNMP.
Parser - defined fields containing the specified data format and creates new metrics based on the
contents of the field
Pivot - rotate single valued metrics into a multi field metric
Rename - renames InfluxDB measurements, fields, and tags
Strings - maps certain Go string functions onto InfluxDB measurement, tag, and field values
TopK - filter designed to get the top series over a period of time
© 2020 InfluxData. All rights reserved. 20
And aggregators!
BasicStats - count, max, min, mean, s2(variance), and stdev for
a set of values, emitting the aggregate every period seconds
Final - emits the last metric of a contiguous series
Merge - merges metrics together and generates line protocol
with multiple fields per line
MinMax - aggregates min and max values of each field it sees
ValueCounter - counts the occurrence of values in fields and
emits the counter once every ‘period’ seconds
AFTER load: Transforming
data with Flux
© 2020 InfluxData. All rights reserved. 22
Why Flux?
InfluxData’s functional data scripting language designed for
querying, analyzing, and acting on data
Flux allows for a lot of capabilities you wouldn’t get with InfluxQL
https://docs.influxdata.com/influxdb/v2.0/query
-data/get-started/
© 2020 InfluxData. All rights reserved. 23
map() functions
Map operates on a row one at a time...
map(fn: (r) => ({ _value: r._value * r._value }))
...re-maps the row record with what it’s operating unless you use
with
map(fn: (r) => ({ r with newColumn: r._value * 2 }))
Things to do with map():
- Basic Mathematical operations
- Conditional Logic
- Adding new columns and tables
© 2020 InfluxData. All rights reserved. 24
Mathematical Operations
import "math"
Flux Math package result
Basic Math math.pi * 6.12 ^ 2.0 117.66646788461355
Basic Math r._value + r._value 2 * r._value
Round math.floor(x: 1.22) 1
Trig math.cos(x: 3.14) -0.9999987317275396
|> map(fn: (r) => ({r with
pizza: math.pi * r._value ^ 2 }))
© 2020 InfluxData. All rights reserved. 25
String manipulations and data shaping
Flux String package result
Concatenation strings.joinStr(arr: ["rain on me", "rain", "rain"], v: ",")
"rain on me, rain,
rain"
Splitting strings.split(v: "rain on me", t: " ") ["rain", "on", "me"]
Substring strings.substring(v: "Lady Gaga", start: 5, end: 8) “Gaga”
Case
conversion
strings.toUpper(v: "chromatica") “CHROMATICA”
Searching
strings.containsStr(v: "it’s coming down on me", substr: "down")
strings.countStr(v: "rain gain pain", substr: "ain")
true
3
import "strings"
|> map(fn: (r) => ({r with
content: strings.replace(v: r.content, t: "Mariah Carey", u: "Lady Gaga", i: 3)}))
© 2020 InfluxData. All rights reserved. 26
Conditional logic: if/then/else
● Conditionally transform column values with map()
if r._value >= 29 then "playoffs!!!"
else if r._value < 29 and r._value >= 26 then "so close"
else "better luck next year"
© 2020 InfluxData. All rights reserved. 27
League Division Name _field _value
AL West Angels Wins 26
AL West Astros Wins 29
AL West Athletics Wins 36
AL East Blue Jays Wins 32
AL Central Indians Wins 35
AL West Mariners Wins 27
AL East Orioles Wins 25
AL West Rangers Wins 22
AL East Rays Wins 40
AL East Red Sox Wins 24
AL Central Royals Wins 26
AL Central Tigers Wins 23
AL Central Twins Wins 36
AL Central White Sox Wins 35
AL East Yankees Wins 33
Conditional logic: if/then/else
|> map(fn: (r) => ({
r with
postseason:
if r._value >= 29
then "playoffs!!!"
else if r._value < 29 and r._value >= 26
then "so close"
else "better luck next year"
})
)
postseason
so close
playoffs!!!
playoffs!!!
playoffs!!!
playoffs!!!
so close
better luck next year
better luck next year
playoffs!!!
better luck next year
so close
better luck next year
playoffs!!!
playoffs!!!
playoffs!!!
Telegraf and Flux both
sound super great!
© 2020 InfluxData. All rights reserved. 29
When to do something in Telegraf or Flux?
Telegraf:
● Tag/field manipulation for data Routing
● Cleaning up data
● Permanent transformations to improve performance on the
query side
Flux:
● Optimizing data for query and analysis
● Creating new columns or tables
● Flexibility
© 2020 InfluxData. All rights reserved. 30
Thank You!!
Telegraf Processors:
https://docs.influxdata.com/telegraf/latest/plugins/
Flux docs: https://docs.influxdata.com/flux
1 of 30

Recommended

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
689 views110 slides
Databus: LinkedIn's Change Data Capture Pipeline SOCC 2012 by
Databus: LinkedIn's Change Data Capture Pipeline SOCC 2012Databus: LinkedIn's Change Data Capture Pipeline SOCC 2012
Databus: LinkedIn's Change Data Capture Pipeline SOCC 2012Shirshanka Das
14.3K views20 slides
YAML Tips For Kubernetes by Neependra Khare by
YAML Tips For Kubernetes by Neependra KhareYAML Tips For Kubernetes by Neependra Khare
YAML Tips For Kubernetes by Neependra KhareCodeOps Technologies LLP
5.4K views19 slides
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti... by
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...confluent
3.7K views25 slides
Using the New Apache Flink Kubernetes Operator in a Production Deployment by
Using the New Apache Flink Kubernetes Operator in a Production DeploymentUsing the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentFlink Forward
649 views17 slides
VMware Tanzu Kubernetes Connect by
VMware Tanzu Kubernetes ConnectVMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu
969 views33 slides

More Related Content

What's hot

Azure Pipelines Multistage YAML - Top 10 Features by
Azure Pipelines Multistage YAML - Top 10 FeaturesAzure Pipelines Multistage YAML - Top 10 Features
Azure Pipelines Multistage YAML - Top 10 FeaturesMarc Müller
74 views46 slides
Introduction to CI/CD by
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CDSteve Mactaggart
14.8K views27 slides
Terraform modules and some of best-practices - March 2019 by
Terraform modules and some of best-practices - March 2019Terraform modules and some of best-practices - March 2019
Terraform modules and some of best-practices - March 2019Anton Babenko
3.9K views102 slides
Kafka 101 by
Kafka 101Kafka 101
Kafka 101Clement Demonchy
2.4K views41 slides
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli... by
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Flink Forward
264 views57 slides
Apache Kafka Best Practices by
Apache Kafka Best PracticesApache Kafka Best Practices
Apache Kafka Best PracticesDataWorks Summit/Hadoop Summit
66K views35 slides

What's hot(20)

Azure Pipelines Multistage YAML - Top 10 Features by Marc Müller
Azure Pipelines Multistage YAML - Top 10 FeaturesAzure Pipelines Multistage YAML - Top 10 Features
Azure Pipelines Multistage YAML - Top 10 Features
Marc Müller74 views
Terraform modules and some of best-practices - March 2019 by Anton Babenko
Terraform modules and some of best-practices - March 2019Terraform modules and some of best-practices - March 2019
Terraform modules and some of best-practices - March 2019
Anton Babenko3.9K views
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli... by Flink Forward
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Flink Forward264 views
Terraform Best Practices - DevOps Unicorns 2019 by Anton Babenko
Terraform Best Practices - DevOps Unicorns 2019Terraform Best Practices - DevOps Unicorns 2019
Terraform Best Practices - DevOps Unicorns 2019
Anton Babenko1.4K views
Snapshot in Hadoop Distributed File System by Bhavesh Padharia
Snapshot in Hadoop Distributed File SystemSnapshot in Hadoop Distributed File System
Snapshot in Hadoop Distributed File System
Bhavesh Padharia388 views
Service Discovery and Registration in a Microservices Architecture by PLUMgrid
Service Discovery and Registration in a Microservices ArchitectureService Discovery and Registration in a Microservices Architecture
Service Discovery and Registration in a Microservices Architecture
PLUMgrid6.7K views
Kafka Tutorial - Introduction to Apache Kafka (Part 1) by Jean-Paul Azar
Kafka Tutorial - Introduction to Apache Kafka (Part 1)Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Jean-Paul Azar8.9K views
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO... by Simplilearn
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Simplilearn2.8K views
Kafka streams windowing behind the curtain by confluent
Kafka streams windowing behind the curtain Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain
confluent1.3K views
Mixer vessel by cfmesh by Etsuji Nomura
Mixer vessel by cfmeshMixer vessel by cfmesh
Mixer vessel by cfmesh
Etsuji Nomura1.8K views
Apache Kafka by emreakis
Apache KafkaApache Kafka
Apache Kafka
emreakis1.2K views
Prometheus – a next-gen Monitoring System by Fabian Reinartz
Prometheus – a next-gen Monitoring SystemPrometheus – a next-gen Monitoring System
Prometheus – a next-gen Monitoring System
Fabian Reinartz5.4K views
The Nextcloud Roadmap for Secure Team Collaboration by Univention GmbH
The Nextcloud Roadmap for Secure Team CollaborationThe Nextcloud Roadmap for Secure Team Collaboration
The Nextcloud Roadmap for Secure Team Collaboration
Univention GmbH1.4K views
Kafka in action - Tech Talk - Paytm by Sumit Jain
Kafka in action - Tech Talk - PaytmKafka in action - Tech Talk - Paytm
Kafka in action - Tech Talk - Paytm
Sumit Jain457 views
신뢰성 높은 클라우드 기반 서비스 운영을 위한 Chaos Engineering in Action (윤석찬, AWS 테크에반젤리스트) :: ... by Amazon Web Services Korea
신뢰성 높은 클라우드 기반 서비스 운영을 위한 Chaos Engineering in Action (윤석찬, AWS 테크에반젤리스트) :: ...신뢰성 높은 클라우드 기반 서비스 운영을 위한 Chaos Engineering in Action (윤석찬, AWS 테크에반젤리스트) :: ...
신뢰성 높은 클라우드 기반 서비스 운영을 위한 Chaos Engineering in Action (윤석찬, AWS 테크에반젤리스트) :: ...

Similar to Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Using Telegraf and Flux | InfluxDays Virtual Experience NA 2020

Accelerating analytics on the Sensor and IoT Data. by
Accelerating analytics on the Sensor and IoT Data. Accelerating analytics on the Sensor and IoT Data.
Accelerating analytics on the Sensor and IoT Data. Keshav Murthy
3.7K views47 slides
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux... by
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...InfluxData
1.2K views47 slides
Spark streaming by
Spark streamingSpark streaming
Spark streamingVenkateswaran Kandasamy
156 views40 slides
strata_spark_streaming.ppt by
strata_spark_streaming.pptstrata_spark_streaming.ppt
strata_spark_streaming.pptrveiga100
9 views40 slides
Analytics with Spark by
Analytics with SparkAnalytics with Spark
Analytics with SparkProbst Ludwine
724 views54 slides
So you think you can stream.pptx by
So you think you can stream.pptxSo you think you can stream.pptx
So you think you can stream.pptxPrakash Chockalingam
542 views48 slides

Similar to Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Using Telegraf and Flux | InfluxDays Virtual Experience NA 2020(20)

Accelerating analytics on the Sensor and IoT Data. by Keshav Murthy
Accelerating analytics on the Sensor and IoT Data. Accelerating analytics on the Sensor and IoT Data.
Accelerating analytics on the Sensor and IoT Data.
Keshav Murthy3.7K views
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux... by InfluxData
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
InfluxData1.2K views
strata_spark_streaming.ppt by rveiga100
strata_spark_streaming.pptstrata_spark_streaming.ppt
strata_spark_streaming.ppt
rveiga1009 views
Productionizing your Streaming Jobs by Databricks
Productionizing your Streaming JobsProductionizing your Streaming Jobs
Productionizing your Streaming Jobs
Databricks1.6K views
Distributed Real-Time Stream Processing: Why and How 2.0 by Petr Zapletal
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0
Petr Zapletal5.5K views
Taking Spark Streaming to the Next Level with Datasets and DataFrames by Databricks
Taking Spark Streaming to the Next Level with Datasets and DataFramesTaking Spark Streaming to the Next Level with Datasets and DataFrames
Taking Spark Streaming to the Next Level with Datasets and DataFrames
Databricks8.6K views
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir... by InfluxData
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...
InfluxData7.4K views
R programming & Machine Learning by AmanBhalla14
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
AmanBhalla14676 views
A Tale of Data Pattern Discovery in Parallel by Jenny Liu
A Tale of Data Pattern Discovery in ParallelA Tale of Data Pattern Discovery in Parallel
A Tale of Data Pattern Discovery in Parallel
Jenny Liu126 views
Deep Dive with Spark Streaming - Tathagata Das - Spark Meetup 2013-06-17 by spark-project
Deep Dive with Spark Streaming - Tathagata  Das - Spark Meetup 2013-06-17Deep Dive with Spark Streaming - Tathagata  Das - Spark Meetup 2013-06-17
Deep Dive with Spark Streaming - Tathagata Das - Spark Meetup 2013-06-17
spark-project53.4K views
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das by Databricks
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Databricks22.1K views
spark stream - kafka - the right way by Dori Waldman
spark stream - kafka - the right way spark stream - kafka - the right way
spark stream - kafka - the right way
Dori Waldman206 views

More from InfluxData

Announcing InfluxDB Clustered by
Announcing InfluxDB ClusteredAnnouncing InfluxDB Clustered
Announcing InfluxDB ClusteredInfluxData
100 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
50 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
134 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
127 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
375 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
InfluxData100 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
InfluxData50 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...
InfluxData134 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
InfluxData127 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
InfluxData375 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
InfluxData391 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...
InfluxData182 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
InfluxData185 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
InfluxData134 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
InfluxData62 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

Transcript: The Details of Description Techniques tips and tangents on altern... by
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...BookNet Canada
135 views15 slides
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensorssugiuralab
19 views15 slides
AMAZON PRODUCT RESEARCH.pdf by
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdfJerikkLaureta
19 views13 slides
Democratising digital commerce in India-Report by
Democratising digital commerce in India-ReportDemocratising digital commerce in India-Report
Democratising digital commerce in India-ReportKapil Khandelwal (KK)
15 views161 slides
Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
30 views43 slides
Microsoft Power Platform.pptx by
Microsoft Power Platform.pptxMicrosoft Power Platform.pptx
Microsoft Power Platform.pptxUni Systems S.M.S.A.
52 views38 slides

Recently uploaded(20)

Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada135 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta19 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman30 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun10 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma31 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
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 Software257 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive

Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Using Telegraf and Flux | InfluxDays Virtual Experience NA 2020

  • 1. Samantha Wang Product Manager, InfluxData Best Practices on How to Transform Your Data Using Telegraf and Flux
  • 2. © 2020 InfluxData. All rights reserved. 2 Why do we transform data? Problems: ● Resource-intensive. ● Lack of expertise and carelessness ● Better-organization ● Facilitates compatibility between applications, systems, and types of data
  • 3. © 2020 InfluxData. All rights reserved. 3 Goals: 1. How to transform your data to fit the optimal state of your monitoring environment 2. Tools for transformation BEFORE data ingestion a. The power of Telegraf processors and aggregators 3. Tools for transformation AFTER data ingestion a. The power of Flux transformation queries
  • 4. Basic data Concepts of InfluxDB
  • 5. © 2020 InfluxData. All rights reserved. 5 What you’re collecting Data ingestion Database!! Visualizations Analytics transform! transform!
  • 6. © 2020 InfluxData. All rights reserved. 6
  • 7. © 2020 InfluxData. All rights reserved. 7 weather,location=us-midwest temperature=82,humidity=71 1465839830100400200 InfluxDB Line Protocol tag(s) field(s) timestamp weather location=us-midwest temperature=82,humidity=71
  • 9. © 2020 InfluxData. All rights reserved. 9 Telegraf CPU Mem Disk Docker Kubernetes /metrics Kafka MySQL Process - transform - decorate - filter Aggregate - mean - min,max - count - variance - stddev InfluxDB File Kafka CloudWatch CloudWatch Input Output
  • 10. © 2020 InfluxData. All rights reserved. 10 Why manipulate data with Telegraf? ● Convert tags ↔ fields or data types ● Rename field names or values ● Aggregate data ● Clean up or filter data ● Perform data transformation as close to the device ● Improve performance
  • 11. © 2020 InfluxData. All rights reserved. 11 Convert Data: [[processors.converter]] [processors.converter.tags] measurement = [] string = [] integer = [] unsigned = [] boolean = [] float = [] [processors.converter.fields] measurement = [] tag = [] string = [] processors.converter
  • 12. © 2020 InfluxData. All rights reserved. 12 Convert tags ↔ fields Convert port tag to a string field: [[processors.converter]] [processors.converter.tags] string = ["port"] - apache,port=80,server=debian-stretch-apache BytesPerReq=0 + apache,server=debian-stretch-apache port="80",BytesPerReq=0 [[processors.converter]] [processors.converter.fields] tag = ["port"] - apache,server=debian-stretch-apache port="80",BytesPerReq=0 + apache,port=80,server=debian-stretch-apache BytesPerReq=0 Convert port field to a tag:
  • 13. © 2020 InfluxData. All rights reserved. 13 Convert data types Convert all scboard_* fields to an integer: [[processors.converter]] [processors.converter.fields] integer = ["scboard_*"] - apache scboard_open=100,scboard_reading=0,scboard_sending=1,scboard_starting=0,scboard_waiting=49 + apache scboard_open=100i,scboard_reading=0i,scboard_sending=1i,scboard_starting=0i,scboard_waiting=49i
  • 14. © 2020 InfluxData. All rights reserved. 14 Mapping: [[processors.enum]] [[processors.enum.mapping]] tag = "StorageType" dest = "StorageName" [processors.enum.mapping.value_mappings] ".1.3.6.1.2.1.25.2.1.1" = "Other" ".1.3.6.1.2.1.25.2.1.2" = "RAM" ".1.3.6.1.2.1.25.2.1.3" = "Virtual Memory" ".1.3.6.1.2.1.25.2.1.4" = "Fixed Disk" ".1.3.6.1.2.1.25.2.1.5" = "Removable Disk" ".1.3.6.1.2.1.25.2.1.6" = "Floppy Disk" ".1.3.6.1.2.1.25.2.1.7" = "Compact Disc" ".1.3.6.1.2.1.25.2.1.8" = "RAM Disk" - snmp StorageType=".1.3.6.1.2.1.25.2.1.6" 1502489900000000000 + snmp StorageName="Floppy Disk",StorageType=".1.3.6.1.2.1.25.2.1.6" 1502489900000000000 Enum Processor: ● value mappings for metric tags or fields ● Common use case is to map status codes processors.enum
  • 15. © 2020 InfluxData. All rights reserved. 15 Transform tags and fields: Regex Processor: ● Change tags and manipulate field values with regex patterns ● Can replace existing field OR produce new tags and fields while maintaining existing ones processors.regex
  • 16. © 2020 InfluxData. All rights reserved. 16 - nginx,resp_code=200 request="/api/search/?category=plugins&q=regex&sort=asc",referrer="-",ident="- ",http_version=1.1,client_ip="127.0.0.1" 1519652321000000000 + nginx,resp_code=2xx request="/api/search/?category=plugins&q=regex&sort=asc",method="/search/",search_category="p lugins",referrer="-",ident="-",http_version=1.1,client_ip="127.0.0.1" 1519652321000000000 [[processors.regex]] namepass = ["nginx"] [[processors.regex.tags]] key = "resp_code" pattern = "^(d)dd$" replacement = "${1}xx" [[processors.regex.fields]] key = "request" pattern = "^/api(?P<method>/[w/]+)S*" replacement = "${method}" result_key = "method" [[processors.regex.fields]] key = "request" pattern = ".*category=(w+).*" replacement = "${1}" result_key = "search_category"
  • 17. © 2020 InfluxData. All rights reserved. 17 Math & Logic Operations: ● Dialect of Python ● Starlark specification (google/starlark-go) has details about the syntax and available functions ● Use Cases: ○ Math operations ○ Logic operations ○ Some string operations ○ Add or remove tags/fields/metrics [[processors.starlark]] ## Source of the Starlark script. source = ''' def apply(metric): return metric ''' ## File containing a Starlark script. # script = "/usr/local/bin/myscript.star" processors.starlark
  • 18. © 2020 InfluxData. All rights reserved. 18 Basic Math - IoT Example w/ Modbus Plugin: Calculate power from voltage & current P = I * V [[processors.starlark]] source = ''' def apply(metric): I = metric.fields['current'] V = metric.fields['voltage'] metric.fields['power'] = I * V return metric ''' - modbus.InputRegisters,host=localhost current=550,frequency=60,voltage=12.93223 1554079521000000000 + modbus.InputRegisters,host=localhost current=550,frequency=60,voltage=12.93223,power=7112.7265 1554079521000000000
  • 19. © 2020 InfluxData. All rights reserved. 19 Other useful transformations Clone - creates a copy of each metric to preserve the original metric and allow modifications in the copied metric Date - adds the metric timestamp as a human readable tag Dedup - filters metrics whose field values are exact repetitions of the previous values. Ifname - processor plugin looks up network interface names using SNMP. Parser - defined fields containing the specified data format and creates new metrics based on the contents of the field Pivot - rotate single valued metrics into a multi field metric Rename - renames InfluxDB measurements, fields, and tags Strings - maps certain Go string functions onto InfluxDB measurement, tag, and field values TopK - filter designed to get the top series over a period of time
  • 20. © 2020 InfluxData. All rights reserved. 20 And aggregators! BasicStats - count, max, min, mean, s2(variance), and stdev for a set of values, emitting the aggregate every period seconds Final - emits the last metric of a contiguous series Merge - merges metrics together and generates line protocol with multiple fields per line MinMax - aggregates min and max values of each field it sees ValueCounter - counts the occurrence of values in fields and emits the counter once every ‘period’ seconds
  • 22. © 2020 InfluxData. All rights reserved. 22 Why Flux? InfluxData’s functional data scripting language designed for querying, analyzing, and acting on data Flux allows for a lot of capabilities you wouldn’t get with InfluxQL https://docs.influxdata.com/influxdb/v2.0/query -data/get-started/
  • 23. © 2020 InfluxData. All rights reserved. 23 map() functions Map operates on a row one at a time... map(fn: (r) => ({ _value: r._value * r._value })) ...re-maps the row record with what it’s operating unless you use with map(fn: (r) => ({ r with newColumn: r._value * 2 })) Things to do with map(): - Basic Mathematical operations - Conditional Logic - Adding new columns and tables
  • 24. © 2020 InfluxData. All rights reserved. 24 Mathematical Operations import "math" Flux Math package result Basic Math math.pi * 6.12 ^ 2.0 117.66646788461355 Basic Math r._value + r._value 2 * r._value Round math.floor(x: 1.22) 1 Trig math.cos(x: 3.14) -0.9999987317275396 |> map(fn: (r) => ({r with pizza: math.pi * r._value ^ 2 }))
  • 25. © 2020 InfluxData. All rights reserved. 25 String manipulations and data shaping Flux String package result Concatenation strings.joinStr(arr: ["rain on me", "rain", "rain"], v: ",") "rain on me, rain, rain" Splitting strings.split(v: "rain on me", t: " ") ["rain", "on", "me"] Substring strings.substring(v: "Lady Gaga", start: 5, end: 8) “Gaga” Case conversion strings.toUpper(v: "chromatica") “CHROMATICA” Searching strings.containsStr(v: "it’s coming down on me", substr: "down") strings.countStr(v: "rain gain pain", substr: "ain") true 3 import "strings" |> map(fn: (r) => ({r with content: strings.replace(v: r.content, t: "Mariah Carey", u: "Lady Gaga", i: 3)}))
  • 26. © 2020 InfluxData. All rights reserved. 26 Conditional logic: if/then/else ● Conditionally transform column values with map() if r._value >= 29 then "playoffs!!!" else if r._value < 29 and r._value >= 26 then "so close" else "better luck next year"
  • 27. © 2020 InfluxData. All rights reserved. 27 League Division Name _field _value AL West Angels Wins 26 AL West Astros Wins 29 AL West Athletics Wins 36 AL East Blue Jays Wins 32 AL Central Indians Wins 35 AL West Mariners Wins 27 AL East Orioles Wins 25 AL West Rangers Wins 22 AL East Rays Wins 40 AL East Red Sox Wins 24 AL Central Royals Wins 26 AL Central Tigers Wins 23 AL Central Twins Wins 36 AL Central White Sox Wins 35 AL East Yankees Wins 33 Conditional logic: if/then/else |> map(fn: (r) => ({ r with postseason: if r._value >= 29 then "playoffs!!!" else if r._value < 29 and r._value >= 26 then "so close" else "better luck next year" }) ) postseason so close playoffs!!! playoffs!!! playoffs!!! playoffs!!! so close better luck next year better luck next year playoffs!!! better luck next year so close better luck next year playoffs!!! playoffs!!! playoffs!!!
  • 28. Telegraf and Flux both sound super great!
  • 29. © 2020 InfluxData. All rights reserved. 29 When to do something in Telegraf or Flux? Telegraf: ● Tag/field manipulation for data Routing ● Cleaning up data ● Permanent transformations to improve performance on the query side Flux: ● Optimizing data for query and analysis ● Creating new columns or tables ● Flexibility
  • 30. © 2020 InfluxData. All rights reserved. 30 Thank You!! Telegraf Processors: https://docs.influxdata.com/telegraf/latest/plugins/ Flux docs: https://docs.influxdata.com/flux