Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retain flag to mqtt output to let brokers/servers cache measurements #4892

Conversation

p-kraszewski
Copy link
Contributor

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Not unit-testable. Behavior confirmed to be correct in-house on the following configuration:

  • FreeBSD 11-STABLE
  • Mosquitto 1.5.3
  • mosquitto.conf:
persistence true
autosave_interval 5
autosave_on_changes true
log_dest syslog
log_type warning
persistence_location /data/mosquitto/
persistent_client_expiration 1w

bind_address 127.0.0.1
port 1300
  • telegraf.conf:
[global_tags]
[agent]
  interval = "60s"
  round_interval = true
  metric_batch_size = 100
  metric_buffer_limit = 10000
  collection_jitter = "500ms"
  flush_interval = "10s"
  flush_jitter = "10s"
  precision = ""
  quiet = true
  hostname = ""
  omit_hostname = false
[[outputs.mqtt]]
  servers = ["localhost:1300"]
  client_id = "telegraf-out"
  qos = 2
  batch = true
  retain = true
  topic_prefix = "telegraf"
[[inputs.cpu]]
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "fdescfs", "procfs"]
[[inputs.diskio]]
  devices = ["ada*", "da*"]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.net]]
[[inputs.syslog]]
  server = "udp4://localhost:6514"
  keep_alive_period = "1m"
  best_effort = true

Broker caches results until they are drained by:

mosquitto_sub -p 1300 -v -t 'telegraf/#' -q 2

Add flag, which - when true - will make broker cache sent entries until someone reads the measurment
Addrd "retail" option description.
@glinton glinton added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin area/mqtt labels Oct 22, 2018
plugins/outputs/mqtt/README.md Show resolved Hide resolved
plugins/outputs/mqtt/mqtt.go Show resolved Hide resolved
plugins/outputs/mqtt/README.md Show resolved Hide resolved
@danielnelson danielnelson added this to the 1.10.0 milestone Jan 8, 2019
@danielnelson danielnelson merged commit 0084138 into influxdata:master Feb 12, 2019
@danielnelson
Copy link
Contributor

Follow up change for review comments: c08b454

trevorwhitney pushed a commit to trevorwhitney/telegraf that referenced this pull request Feb 14, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
dupondje pushed a commit to dupondje/telegraf that referenced this pull request Apr 22, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mqtt feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants