Created
September 3, 2020 13:49
-
-
Save shantanoo-desai/5399f98476d0cacc0746a6fa75ef1a1b to your computer and use it in GitHub Desktop.
Telegraf Configuration to connect to an MQTT Broker and converting Field to a Tag for InfluxDB
This file contains hidden or 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 = "2s" | |
round_interval = true | |
metric_batch_size = 1000 | |
metric_buffer_limit = 12000000 | |
precision = "ms" | |
## Logging configuration: | |
## Run telegraf with debug log messages. | |
debug = true | |
## Run telegraf in quiet mode (error log messages only). | |
quiet = false | |
## If set to true, do no set the "host" tag in the telegraf agent. | |
omit_hostname = false | |
# OUTPUT PLUGIN | |
[[outputs.influxdb]] | |
urls = ["https://<MY_INFLUXDBV1_INSTANCE:8086"] | |
database = "PROJ" | |
skip_database_creation = false | |
# User Credentials + TLS Verify settings go here | |
# PROCESSOR PLUGIN | |
[[processors.enum]] | |
order = 1 | |
[[processors.enum.mapping]] | |
field = "result" | |
dest = "value" | |
[processors.enum.mapping.value_mappings] | |
"GOOD" = 0 | |
"BAD" = 1 | |
[[processors.converter]] | |
order = 2 | |
[processors.converter.fields] | |
tag = ["result"] | |
# INPUT PLUGIN | |
[[inputs.mqtt_consumer]] | |
servers = [ "ssl://MY_MQTT_BROKER:8883" ] | |
# Topics to subscribe to: | |
topics = [ | |
"PROJ/system/status" | |
] | |
# User Credentials and TLS Settings go here. | |
# Incoming MQTT Payload is in JSON format with fixed schema | |
data_format = "json" | |
json_name_key = "name" | |
json_string_fields = ["result"] | |
json_time_format = "2006-01-02 15:04:05.000" | |
json_time_key = "timestamp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Write up available: https://shantanoo-desai.github.io/posts/technology/nugget_tags_fields_mgmt_with_telegraf_influxdb/