influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.9k stars 5.6k forks source link

Database creation failed: unable to decode json #2095

Closed ghost closed 8 years ago

ghost commented 8 years ago

I am sending RabbitMQ metrics to InfluxDB using Telegraf. While running telegraf I am facing this issue. 2016/11/28 11:47:47 E! Database creation failed: unable to decode json: received status code 405 err: invalid character 'M' looking for beginning of value

Relevant telegraf.conf:

# Telegraf Configuration
#
# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared inputs, and sent to the declared outputs.
#
# Plugins must be declared in here to be active.
# To deactivate a plugin, comment out the name and any variables.
#
# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
# file would generate.
#
# Environment variables can be used anywhere in this config file, simply prepend
# them with $. For strings the variable must be within quotes (ie, "$STR_VAR"),
# for numbers and booleans they should be plain (ie, $INT_VAR, $BOOL_VAR)

# Global tags can be specified here in key="value" format.
[global_tags]
  # dc = "us-east-1" # will tag all metrics with dc=us-east-1
  # rack = "1a"
  ## Environment variables can be used as tags, and throughout the config file
   user = "$USER"

# Configuration for telegraf agent
[agent]
  ## Default data collection interval for all inputs
  interval = "10s"
  ## Rounds collection interval to 'interval'
  ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
  round_interval = true

  ## Telegraf will send metrics to outputs in batches of at most
  ## metric_batch_size metrics.
  ## This controls the size of writes that Telegraf sends to output plugins.
  metric_batch_size = 1000

  ## For failed writes, telegraf will cache metric_buffer_limit metrics for each
  ## output, and will flush this buffer on a successful write. Oldest metrics
  ## are dropped first when this buffer fills.
  ## This buffer only fills when writes fail to output plugin(s).
  metric_buffer_limit = 10000

  ## Collection jitter is used to jitter the collection by a random amount.
  ## Each plugin will sleep for a random time within jitter before collecting.
  ## This can be used to avoid many plugins querying things like sysfs at the
  ## same time, which can have a measurable effect on the system.
  collection_jitter = "0s"

  ## Default flushing interval for all outputs. You shouldn't set this below
  ## interval. Maximum flush_interval will be flush_interval + flush_jitter
  flush_interval = "10s"
  ## Jitter the flush interval by a random amount. This is primarily to avoid
  ## large write spikes for users running a large number of telegraf instances.
  ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
  flush_jitter = "0s"

  ## By default, precision will be set to the same timestamp order as the
  ## collection interval, with the maximum being 1s.
  ## Precision will NOT be used for service inputs, such as logparser and statsd.
  ## Valid values are "ns", "us" (or "µs"), "ms", "s".
  precision = ""

  ## Logging configuration:
  ## Run telegraf with debug log messages.
  debug = false
  ## Run telegraf in quiet mode (error log messages only).
  quiet = false
  ## Specify the log file name. The empty string means to log to stderr.
  logfile = ""

  ## Override default hostname, if empty use os.Hostname()
  hostname = ""
  ## If set to true, do no set the "host" tag in the telegraf agent.
  omit_hostname = false
###############################################################################
#                            OUTPUT PLUGINS                                   #
###############################################################################

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  ## The full HTTP or UDP endpoint URL for your InfluxDB instance.
  ## Multiple urls can be specified as part of the same cluster,
  ## this means that only ONE of the urls will be written to each interval.
  # urls = ["udp://localhost:8089"] # UDP endpoint example
  urls = ["http://localhost:8086"] # required
  ## The target database for metrics (telegraf will create it if not exists).
  database = "telegraf" # required

  ## Retention policy to write to. Empty string writes to the default rp.
  retention_policy = ""
  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
  write_consistency = "any"

  ## Write timeout (for the InfluxDB client), formatted as a string.
  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
  timeout = "5s"
# # Read metrics from one or many RabbitMQ servers via the management API
 [[inputs.rabbitmq]]
    url = "http://localhost:15672"
    name = "rmq-server-1" # optional tag
    username = "guest"
    password = "guest"

System info:

OS : Ubuntu 16.04 LTS Telegraf Version : V1.1.1 InfluxDB version : V0.10.0 RabbitMQ version : V3.6.6-1

Expected behavior: It should send metrics to inlfuxDB.

Complete error log:

2016/11/28 11:47:47 I! Using config file: /etc/telegraf/telegraf.conf
2016/11/28 11:47:47 E! Database creation failed: unable to decode json: received status code 405 err: invalid character 'M' looking for beginning of value
2016/11/28 11:47:47 I! Starting Telegraf (version 1.1.1)
2016/11/28 11:47:47 I! Loaded outputs: influxdb
2016/11/28 11:47:47 I! Loaded inputs: inputs.processes inputs.system inputs.rabbitmq inputs.disk inputs.diskio inputs.kernel inputs.mem inputs.swap inputs.cpu
2016/11/28 11:47:47 I! Tags enabled: host=voyalab-ThinkPad-E460 user=voyalab
2016/11/28 11:47:47 I! Agent Config: Interval:10s, Quiet:false, Hostname:"voyalab-ThinkPad-E460", Flush Interval:10s 
2016/11/28 11:48:00 I! Output [influxdb] buffer fullness: 41 / 10000 metrics. Total gathered metrics: 41. Total dropped metrics: 0.
2016/11/28 11:48:00 E! Database creation failed: unable to decode json: received status code 405 err: invalid character 'M' looking for beginning of value
2016/11/28 11:48:00 E! Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster
2016/11/28 11:48:10 I! Output [influxdb] buffer fullness: 64 / 10000 metrics. Total gathered metrics: 64. Total dropped metrics: 0.
2016/11/28 11:48:10 E! Database creation failed: unable to decode json: received status code 405 err: invalid character 'M' looking for beginning of value
2016/11/28 11:48:10 E! Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster
^C2016/11/28 11:48:15 I! Hang on, flushing any cached metrics before shutdown
2016/11/28 11:48:15 I! Output [influxdb] buffer fullness: 64 / 10000 metrics. Total gathered metrics: 64. Total dropped metrics: 0.
2016/11/28 11:48:15 E! Database creation failed: unable to decode json: received status code 405 err: invalid character 'M' looking for beginning of value
2016/11/28 11:48:15 E! Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster

Am I missing something ?

sparrc commented 8 years ago

you'll need to either downgrade telegraf to 0.10.x or upgrade your infludb to 1.1.x. Mismatched versions are not supported at the moment.