From 3072b5a493de7cd62b9ce05fe8052aa31eb852e3 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Fri, 18 May 2018 19:03:00 -0700 Subject: [PATCH] Update mqtt output docs and changelog --- CHANGELOG.md | 1 + etc/telegraf.conf | 84 +++++++++++++++++++++++++++++++--- plugins/outputs/mqtt/README.md | 14 +++--- plugins/outputs/mqtt/mqtt.go | 25 +++++----- 4 files changed, 97 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21839b50b..68893bf6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - [#3455](https://github.com/influxdata/telegraf/pull/3455): Add tag/integer pair for result to net_response. - [#4010](https://github.com/influxdata/telegraf/pull/3455): Add application_insights output plugin. - [#4167](https://github.com/influxdata/telegraf/pull/4167): Added several important elasticsearch cluster health metrics. +- [#4094](https://github.com/influxdata/telegraf/pull/4094): Add batch mode to mqtt output. ### Bugfixes diff --git a/etc/telegraf.conf b/etc/telegraf.conf index ef0f95caf..1e7e8bed1 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -198,6 +198,26 @@ # data_format = "influx" +# # Send metrics to Azure Application Insights +# [[outputs.application_insights]] +# ## Instrumentation key of the Application Insights resource. +# instrumentation_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx" +# +# ## Timeout for closing (default: 5s). +# # timeout = "5s" +# +# ## Enable additional diagnostic logging. +# # enable_diagnosic_logging = false +# +# ## Context Tag Sources add Application Insights context tags to a tag value. +# ## +# ## For list of allowed context tag keys see: +# ## https://github.com/Microsoft/ApplicationInsights-Go/blob/master/appinsights/contracts/contexttagkeys.go +# # [outputs.application_insights.context_tag_sources] +# # "ai.cloud.role" = "kubernetes_container_name" +# # "ai.cloud.roleInstance" = "kubernetes_pod_name" + + # # Configuration for AWS CloudWatch output. # [[outputs.cloudwatch]] # ## Amazon REGION @@ -341,6 +361,40 @@ # servers = ["127.0.0.1:12201", "192.168.1.1:12201"] +# # A plugin that can transmit metrics over HTTP +# [[outputs.http]] +# ## URL is the address to send metrics to +# url = "http://127.0.0.1:8080/metric" +# +# ## Timeout for HTTP message +# # timeout = "5s" +# +# ## HTTP method, one of: "POST" or "PUT" +# # method = "POST" +# +# ## HTTP Basic Auth credentials +# # username = "username" +# # password = "pa$$word" +# +# ## Additional HTTP headers +# # [outputs.http.headers] +# # # Should be set to "application/json" for json data_format +# # Content-Type = "text/plain; charset=utf-8" +# +# ## Optional TLS Config +# # tls_ca = "/etc/telegraf/ca.pem" +# # tls_cert = "/etc/telegraf/cert.pem" +# # tls_key = "/etc/telegraf/key.pem" +# ## Use TLS but skip chain & host verification +# # insecure_skip_verify = false +# +# ## Data format to output. +# ## Each data format has it's own unique set of configuration options, read +# ## more about them here: +# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md +# # data_format = "influx" + + # # Configuration for sending metrics to an Instrumental project # [[outputs.instrumental]] # ## Project API Token (required) @@ -527,16 +581,22 @@ # ## ex: prefix/web01.example.com/mem # topic_prefix = "telegraf" # +# ## QoS policy for messages +# ## 0 = at most once +# ## 1 = at least once +# ## 2 = exactly once +# # qos = 2 +# # ## username and password to connect MQTT server. # # username = "telegraf" # # password = "metricsmetricsmetricsmetrics" # -# ## Timeout for write operations. default: 5s -# # timeout = "5s" -# # ## client ID, if not set a random ID is generated # # client_id = "" # +# ## Timeout for write operations. default: 5s +# # timeout = "5s" +# # ## Optional TLS Config # # tls_ca = "/etc/telegraf/ca.pem" # # tls_cert = "/etc/telegraf/cert.pem" @@ -544,6 +604,10 @@ # ## Use TLS but skip chain & host verification # # insecure_skip_verify = false # +# ## When true, metrics will be sent in one MQTT message per flush. Otherwise, +# ## metrics are written one metric per MQTT message. +# # batch = false +# # ## Data format to output. # ## Each data format has its own unique set of configuration options, read # ## more about them here: @@ -1169,6 +1233,11 @@ # # tls_key = "/etc/telegraf/key.pem" # ## Use TLS but skip chain & host verification # # insecure_skip_verify = true +# +# ## Consul checks' tag splitting +# # When tags are formatted like "key:value" with ":" as a delimiter then +# # they will be splitted and reported as proper key:value in Telegraf +# # tag_delimiter = ":" # # Read metrics from one or many couchbase clusters @@ -1791,19 +1860,19 @@ # ## List of metrics collected on above servers # ## Each metric consists in a name, a jmx path and either # ## a pass or drop slice attribute. -# ## This collect all heap memory usage metrics. +# ## This collect all heap memory usage metrics. # [[inputs.jolokia.metrics]] # name = "heap_memory_usage" # mbean = "java.lang:type=Memory" # attribute = "HeapMemoryUsage" # -# ## This collect thread counts metrics. +# ## This collect thread counts metrics. # [[inputs.jolokia.metrics]] # name = "thread_count" # mbean = "java.lang:type=Threading" # attribute = "TotalStartedThreadCount,ThreadCount,DaemonThreadCount,PeakThreadCount" # -# ## This collect number of class loaded/unloaded counts metrics. +# ## This collect number of class loaded/unloaded counts metrics. # [[inputs.jolokia.metrics]] # name = "class_count" # mbean = "java.lang:type=ClassLoading" @@ -2259,7 +2328,7 @@ # reverse_metric_names = true -# # A plugin to collect stats from Opensmtpd - a validating, recursive, and caching DNS resolver +# # A plugin to collect stats from Opensmtpd - a validating, recursive, and caching DNS resolver # [[inputs.opensmtpd]] # ## If running as a restricted user you can prepend sudo for additional access: # #use_sudo = false @@ -3561,3 +3630,4 @@ # [[inputs.zipkin]] # # path = "/api/v1/spans" # URL path for span data # # port = 9411 # Port on which Telegraf listens + diff --git a/plugins/outputs/mqtt/README.md b/plugins/outputs/mqtt/README.md index 716806783..14c166f9e 100644 --- a/plugins/outputs/mqtt/README.md +++ b/plugins/outputs/mqtt/README.md @@ -11,6 +11,9 @@ This plugin writes to a [MQTT Broker](http://http://mqtt.org/) acting as a mqtt topic_prefix = "telegraf" ## QoS policy for messages + ## 0 = at most once + ## 1 = at least once + ## 2 = exactly once qos = 2 ## username and password to connect MQTT server. @@ -30,17 +33,12 @@ This plugin writes to a [MQTT Broker](http://http://mqtt.org/) acting as a mqtt ## Use TLS but skip chain & host verification # insecure_skip_verify = false - ## Batch messages in a topic - ## batch = false - ## Flag to determine if messages sent in a topic in a flush interval, - ## need to be batched into one message. - ## batch = true, batches the messages in a topic to one messages - ## batch = false, default behaviour + ## When true, metrics will be sent in one MQTT message per flush. Otherwise, + ## metrics are written one metric per MQTT message. # batch = false - ## Data format to output. - data_format = "influx" + # data_format = "influx" ``` ### Required parameters: diff --git a/plugins/outputs/mqtt/mqtt.go b/plugins/outputs/mqtt/mqtt.go index 5228a083a..6231045b8 100644 --- a/plugins/outputs/mqtt/mqtt.go +++ b/plugins/outputs/mqtt/mqtt.go @@ -23,16 +23,22 @@ var sampleConfig = ` ## ex: prefix/web01.example.com/mem topic_prefix = "telegraf" + ## QoS policy for messages + ## 0 = at most once + ## 1 = at least once + ## 2 = exactly once + # qos = 2 + ## username and password to connect MQTT server. # username = "telegraf" # password = "metricsmetricsmetricsmetrics" - ## Timeout for write operations. default: 5s - # timeout = "5s" - ## client ID, if not set a random ID is generated # client_id = "" + ## Timeout for write operations. default: 5s + # timeout = "5s" + ## Optional TLS Config # tls_ca = "/etc/telegraf/ca.pem" # tls_cert = "/etc/telegraf/cert.pem" @@ -40,20 +46,15 @@ var sampleConfig = ` ## Use TLS but skip chain & host verification # insecure_skip_verify = false + ## When true, metrics will be sent in one MQTT message per flush. Otherwise, + ## metrics are written one metric per MQTT message. + # batch = false + ## Data format to output. ## Each data format has its own unique set of configuration options, read ## more about them here: ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md data_format = "influx" - - ## Batch messages in a topic - ## batch = false - ## Flag to determine if messages sent in a topic in a flush interval, - ## need to be batched into one message. - ## batch = true, batches the messages in a topic to one messages - ## batch = false, default behaviour - # batch = false - ` type MQTT struct {