使用Telegraf解析JSON时出现问题
我想用Telegraf从一个招摇过市的API收集数据 这是我的telegraf.conf中的DS定义使用Telegraf解析JSON时出现问题,json,http,swagger,telegraf,Json,Http,Swagger,Telegraf,我想用Telegraf从一个招摇过市的API收集数据 这是我的telegraf.conf中的DS定义 [[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
[[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请求返回以下字符串
{“ethernet”:{“connected”:true,“enabled”:true},“wifi”:{“connected”:false,“enabled”:false,“mode”:“CABLE”,“ssid”:“UM-NO-HOTSPOT-NAME-SET”},“wifi_网络”:[]}
Telegraf——测试返回以下内容
httpjson\u ultimaker\u状态,主机=dmon虚拟机,服务器=response\u时间=7.333277032 15511057700000000
我希望字符串“connected”不是15511057700000000
我怎样才能得到预期的结果
感谢您的帮助,在块开头的telegraf.conf文件中使用json插件,它说:
“注意,此插件仅读取数值测量值,字符串和布尔值将被忽略。”除非在标记键或JSON字符串字段选项中指定,否则JSON字符串将被忽略 也许你可以试试,比如 标记键=[“以太网连接”] json_字符串_字段=[“以太网_连接”] 更多您可以在