influxdata / sandbox

A sandbox for the full TICK stack
MIT License
484 stars 219 forks source link

Connection refused when wirint to influxDB via Telegraf #35

Open GillesC opened 6 years ago

GillesC commented 6 years ago

I try to receive MQTT data and store it in a local influxdb. However, when receiving the MQTT data I get the following error when running telegraf --debug:

2018-06-22T09:37:20Z E! [outputs.influxdb]: when writing to [http://127.0.0.1:8086]: Post http://127.0.0.1:8086/write?consistency=any&db=iotree: dial tcp 127.0.0.1:8086: connect: connection refused
2018-06-22T09:37:20Z E! Error writing to output [influxdb]: could not write any address

Sometimes when this error occurs I am not able to attach to the influxdb cli and it says 'no container found'.

Telegraf config file (removed sensitive information, e.g. passwords):

[agent]
  interval = "5s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "5s"
  flush_jitter = "0s"
  precision = ""
  debug = false
  quiet = false
  logfile = ""
  hostname = "$HOSTNAME"
  omit_hostname = false

[[outputs.influxdb]]
  urls = ["http://127.0.0.1:8086"]
  database = "<removed>"
  username = ""
  password = ""
  retention_policy = ""
  write_consistency = "any"
  timeout = "5s"

# Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
  ## MQTT broker URLs to be used. The format should be scheme://host:port,
  ## schema can be tcp, ssl, or ws.
  servers = ["tcp://<removed>:1883"]
  ## MQTT QoS, must be 0, 1, or 2
  qos = 0
  ## Connection timeout for initial connection in seconds
  connection_timeout = "30s"

  ## Topics to subscribe to
  topics = [
    "<removed>/devices/+/up"
  ]

  # if true, messages that can't be delivered while the subscriber is offline
  # will be delivered when it comes back (such as on service restart).
  # NOTE: if true, client_id MUST be set
  persistent_session = false
  # If empty, a random client ID will be generated.
  client_id = ""

  ## username and password to connect MQTT server.
  username = "<removed>"
  password = "<removed>"

  ## 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 consume.
  ## 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_INPUT.md
  data_format = "json"
  name_suffix = "_tree"
  tag_keys = [
    "<removed>"
  ]

Host:

zachjacobs commented 5 years ago

Did you ever fix this? I get the same error in a default windows 10 sandbox install.