MQTT 生产者 Telegraf 输出插件

免费使用此 InfluxDB 集成

MQTT 是一种机器到机器(M2M)/物联网通信协议,设计为轻量级的发布/订阅消息工具。MQTT 对于需要小资源占用和/或网络带宽受限的连接非常有用。MQTT 由 IBM 的 Andy Stanford-Clark 博士和阿伦·尼珀(Arlen Nipper)于 1999 年创建。当时,IBM 正在与一家石油和天然气公司合作,该公司需要从偏远地区的石油管道中提取数据,这需要一个符合这些要求的新的协议。结果就是 MQTT。

IBM 内部使用了 MQTT,直到他们在 2010 年发布了 MQTT 3.1 规范,允许其他人创建自己的 MQTT 实现。开发者很快意识到 MQTT 对物联网相关用例的价值,并且其采用率迅速增长,创建了众多开源代理和客户端库。2013 年,IBM 将 MQTT 提交给 OASIS 进行维护和标准化。

为什么使用 MQTT 生产者 Telegraf 输出插件?

MQTT 生产者 Telegraf 输出插件可以轻松地将数据发送到您的 MQTT 代理。这意味着您可以利用 200 多个 Telegraf 输入插件 来接收数据,使用自定义或预制的 Telegraf 处理器插件 来转换您的数据,然后最终将数据输出到您的 MQTT 代理。

如何使用 MQTT 生产者 Telegraf 输出插件

MQTT 生产者 Telegraf 输出插件易于设置和快速运行。您只需配置 Telegraf YAML 配置文件。以下是一个包含所有可用配置选项的基本示例

# Configuration for MQTT server to send metrics to
[[outputs.mqtt]]
  ## MQTT Brokers
  ## The list of brokers should only include the hostname or IP address and the
  ## port to the broker. This should follow the format `[{scheme}://]{host}:{port}`. For
  ## example, `localhost:1883` or `mqtt://127.0.0.1:1883`.
  ## Scheme can be any of the following: tcp://, mqtt://, tls://, mqtts://
  ## non-TLS and TLS servers can not be mix-and-matched.
  servers = ["localhost:1883", ] # or ["mqtts://tls.example.com:1883"]

  ## Protocol can be `3.1.1` or `5`. Default is `3.1.1`
  # protocol = "3.1.1"

  ## MQTT Topic for Producer Messages
  ## MQTT outputs send metrics to this topic format:
  ## 'topic_prefix/'hostname'/'pluginname'/ (e.g. prefix/web01.example.com/mem)
  topic_prefix = "telegraf"

  ## QoS policy for messages
  ## The mqtt QoS policy for sending messages.
  ## See https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q029090_.htm
  ##   0 = at most once
  ##   1 = at least once
  ##   2 = exactly once
  # qos = 2

  ## Keep Alive
  ## Defines the maximum length of time that the broker and client may not
  ## communicate. Defaults to 0 which turns the feature off.
  ##
  ## For version v2.0.12 and later mosquitto there is a bug
  ## (see https://github.com/eclipse/mosquitto/issues/2117), which requires
  ## this to be non-zero. As a reference eclipse/paho.mqtt.golang defaults to 30.
  # keep_alive = 0

  ## username and password to connect MQTT server.
  # username = "telegraf"
  # password = "metricsmetricsmetricsmetrics"

  ## client ID
  ## The unique client id to connect MQTT server. If this parameter is not set
  ## then 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"
  # tls_key = "/etc/telegraf/key.pem"

  ## 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

  ## When true, metric will have RETAIN flag set, making broker cache entries until someone
  ## actually reads it
  # retain = false

  ## 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"
有关更多信息,请参阅文档。

项目 URL   文档

相关资源

InfluxDb-cloud-logo

最强大的时间序列
数据库作为服务

免费开始
Influxdbu

开发者教育

针对时间序列应用程序开发者的培训。

查看所有教育