Collecting IoT Data in InfluxDB
Collecting IoT Data in InfluxDB
D AVID G . S IM M ON S
S E N I O R D E V E L O P E R E VA N G E L I S T
@ D AVID G S IOT
Who, What and Why is
InfluxData
ü Founded in 2013
ü Delivering a modern open-
source platform for metrics and
events
ü Guiding principles:
• Developer Happiness
• Ease of Development + Scale
Out
Overview • Time to Awesome
ü Results
• 70,000+ Active Servers
• 300+ Customers
Specialized Platforms
different?
3 Need for Scalability and Availability
InfluxData Open Source Projects
Source: https://www.networkworld.com/article/3247801/internet-of-
things/the-top-5-user-requirements-of-iot-edge-platforms.html
Protocol Support
• Normalization of data
• Use Kapacitor for data normalization
• Storage for local data
• Store locally on the edge
• Forward upstream to cloud
• Downsample before forwarding to reduce bandwidth usage
• Local Even Processing Engine
• Use Kapacitor for event processing
Hardware Agnostic, Scalable
• In the Cloud
• High-capacity data ingestion
• Flexible Data retention policies
• Not all data needs to be around forever!
• Dashboarding and visualization
• Alerting
• Response to data events
What Does an IoT Data Solution Need?
• At the edge
• Same needs as the cloud +
• Small, lightweight, yet powerful
• Data downsampling
• Multi-protocol ingestion
An IoT Architecture
• Relationships between
different kinds of data
• Transactional
• Frequently updated
Document Data
• Document storage
• JSON Objects
• NoSQL Databases
Time Series Data
• Data over time
• Stock prices
• Event Data
• event@time
• Sensor Readings
• temperature@time
Why is IoT Data Time Series Data?
• <sensor>@<time>
• The @time component!
• Temperature reading, valve
flow-rate, etc.
• IoT Data is time series
data
• See above.
<sensor>@<time>
Installing InfluxDB
Mac OS X
• Install Homebrew
• /usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/mast
er/install)”
• Install InfluxDB
• brew install influxdb chronograf telegraf kapacitor
• Enable InfluxDB
• brew services start influxdb
• …
Linux
• https://docs.influxdata.com/influxdb/v1.5/introdu
ction/installation/
• curl -sL https://repos.influxdata.com/influxdb.key |
sudo apt-key add –
• source /etc/lsb-release
• echo "deb https://repos.influxdata.com/${DISTRIB_ID,,}
${DISTRIB_CODENAME} stable" | sudo tee
/etc/apt/sources.list.d/influxdb.list
• sudo apt-get install influxdb chronograf telegraf
kapacitor
• systemctl enable influxdb
• …
Windows
• https://portal.influxdata.com/downloads
• Not well supported and not recommended for production
Running InfluxDB
• Go to http://localhost:8888/
• Graphical front-end to InfluxDB, Chronograf, and Kapacitor
Getting Data In
How does InfluxData help?
Tag Set Optional All tag key-value pairs for the Tag keys and tag values are both
point. strings.
Field Set Required. Points must have at least 1 field. All field key-value pairs for Field keys are strings. Field
the point. values can be floats, integers,
strings, or booleans.
Timestamp Optional. InfluxDB uses the server’s local The timestamp for the data Unix nanosecond timestamp.
nanosecond timestamp in UTC if the timestamp is point. InfluxDB accepts one Specify alternative precisions
not included with the point. timestamp per point. with the HTTP API.
InfluxData
• Telegraf
• Data Collection
• InfluxDB
• Short-term storage
• Long-term storage
• Kapacitor
• Local Alerts
• System-wide alerts
• Chronograf
• Dashboards
Getting Data Out
Event Processing Engine
• Kapacitor
• Data co-processing engine
• Downsampling, etc.
• Anomaly detection
• Alerting
Kapacitor Alerting
• Alert Types
• Threshold Alert
• Deadman Alert
• Alerts based on Calculated Value
• …
• Alert Mechanisms
• TCP/HTTP
• Pager Duty
• MQTT
• …
Kapacitor Alert - Calculated Value
var parseTemp =
'’’ {{ if (gt ( index .Fields "max.value" ) 90.0 ) }} #ff0000
{{ else if (gt ( index .Fields "max.value" ) 88.0 ) }} #ff4000
{{ else if (gt ( index .Fields "max.value" ) 86.0 ) }} #ff8000
{{ else if (gt ( index .Fields "max.value" ) 84.0 ) }} #ffbf00
{{ else if (gt ( index .Fields "max.value" ) 82.0 ) }} #ffff00
{{ else if (gt ( index .Fields "max.value" ) 80.0 ) }} #bfff00
…
{{ else }} #bf00ff {{ end }}'''
Kapacitor Alert - MQTT
trigger
|alert()
.mqtt('colorChange')
.brokerName('127.0.0.1')
.topic(message)
Join Our Community
• On the Web
https://community.influxdata.com
• On GitHub
https://github.com/influxdata
• On Slack
https://gophersinvite.herokuapp.com
#influxdb
• On Twitter:
@InfluxDB and @davidgsIoT
Questions?
Thank You
[email protected]
@davidgsIoT