Forked from shantanoo-desai/LineProtocolPayload.txt
Last active
July 29, 2020 19:19
-
-
Save ssoroka/04a10106e55a9915ed74c646dba5b233 to your computer and use it in GitHub Desktop.
telegraf configuration file that connects to Mosquitto Open broker and pushes data into InfluxDB v1.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For Telegraf v1.13 | |
docker run --name=telegrafv1.13 -v $pwd/telegraf.conf:/etc/telegraf.conf:ro --net=host telegraf:1.13 | |
# For Telegraf v1.15 | |
docker run --name=telegrafv1.15 -v $pwd/telegraf.conf/etc/telegraf.conf:ro --net=host telegraf:1.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IOT/sensor2/temp | |
env,type=A temp=23.39 | |
env,type=B temp=40.00 | |
# IOT/sensor1/acc | |
env,type=A x=0.2 | |
env,type=B x=1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"publishTopics": [ | |
{ | |
"name": "IOT/sensor1/acc" | |
}, | |
{ | |
"name": "IOT/sensor2/temp" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[agent] | |
interval = "20s" | |
round_interval = true | |
metric_batch_size = 1000 | |
metric_buffer_limit = 10000 | |
collection_jitter = "0s" | |
flush_interval = "10s" | |
flush_jitter = "0s" | |
precision = "" | |
debug = true | |
quiet = false | |
hostname = "" | |
omit_hostname = true | |
############################################################# | |
# OUTPUT PLUGINS # | |
############################################################# | |
[[outputs.influxdb]] | |
urls = [ "http://influxdb:8086" ] | |
database = "mqtelegraftest" | |
skip_database_creation = false | |
timeout = "5s" | |
############################################################### | |
# PROCESSOR PLUGINS # | |
############################################################### | |
[[processors.regex]] | |
order = 1 | |
[[processors.regex.tags]] | |
# use the `topic` tag to extract information from the MQTT Topic | |
key = "topic" | |
# Topic: IOT/<SENSOR_ID>/<measurement> | |
# Extract <SENSOR_ID> | |
pattern = ".*/(.*)/.*" | |
# Replace the first occurrence | |
replacement = "${1}" | |
# Store it in tag called: | |
result_key = "sensorID" | |
[[processors.enum]] | |
order = 2 | |
[[processors.enum.mapping]] | |
# create a mapping between extracted sensorID and some meta-data | |
tag = "sensorID" | |
dest = "location" | |
[processors.enum.mapping.value_mappings] | |
"sensor1" = "kitchen" | |
"sensor2" = "livingroom" | |
"sensor3" = "bedroom" | |
################################################################## | |
# INPUT PLUGINS # | |
################################################################## | |
[[inputs.mqtt_consumer]] | |
servers = [ "tcp://test.mosquitto.org:1883" ] | |
# Topics to subscribe to: | |
topics = [ | |
"IOT/+/acc", | |
"IOT/+/mag", | |
"IOT/+/gyro", | |
"IOT/+/temp" | |
] | |
# Telegraf will also store the topic as a tag with name `topic` | |
# NOTE: necessary for the Processor REGEX to extract <Sensor_ID> | |
topic_tag = "topic" | |
# Connection timeout | |
connection_timeout = "30s" | |
# Incoming MQTT Payload from Sensor nodes is in InfluxDB Line Protocol strings | |
data_format = "influx" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment