Проблемы разбора JSON с Telegraf - PullRequest
0 голосов
/ 25 февраля 2019

Я хочу собрать данные из API Swagger с помощью Telegraf

Это определение DS в моем telegraf.conf

[[inputs.httpjson]]
  ## NOTE This plugin only reads numerical measurements, strings and booleans
  ## will be ignored.

  ## Name for the service being polled.  Will be appended to the name of the
  ## measurement e.g. "httpjson_webserver_stats".
  ##
  ## Deprecated (1.3.0): Use name_override, name_suffix, name_prefix instead.
  name = "ultimaker_status"

  ## URL of each server in the service's cluster
  servers = [
    "http://192.168.5.15/api/v1/printer/network",
  ]
  ## Set response_timeout (default 5 seconds)
  response_timeout = "15s"

  ## HTTP method to use: GET or POST (case-sensitive)
  method = "GET"

  ## Tags to extract from top-level of JSON server response.
   tag_keys = [
     "ethernet:connected"
   ]

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

  ## HTTP Request Parameters (all values must be strings).  For "GET" requests, data
  ## will be included in the query.  For "POST" requests, data will be included
  ## in the request body as "x-www-form-urlencoded".
  # [inputs.httpjson.parameters]
  #   event_type = "cpu_spike"
  #   threshold = "0.75"

  ## HTTP Request Headers (all values must be strings).
  # [inputs.httpjson.headers]
  #   X-Auth-Token = "my-xauth-token"
  #   apiVersion = "v1"

HTTP-запрос к http://192.168.5.15/api/v1/printer/network возвращаетследующая строка

{"ethernet": {"connected": true, "enabled": true}, "wifi": {"connected": false, "enabled": false, "mode": "CABLE "," ssid ":" UM-NO-HOTSPOT-NAME-SET "}," wifi_networks ": []}

Telegraf --test возвращает следующее

httpjson_ultimaker_status, host =dmon-virtual-machine, server = http://192.168.5.15/api/v1/printer/network response_time = 7.333277032 1551105770000000000

Я ожидаю, что строка «подключена», а не 1551105770000000000

Как получить ожидаемый результат

Спасибо за вашу помощь

1 Ответ

0 голосов
/ 03 апреля 2019

В файле telegraf.conf в начале блока с плагином json написано:
«ПРИМЕЧАНИЕ Этот плагин читает только числовые измерения, строки и логические значения будут игнорироваться».

...