HTTP 响应输入插件
此插件从 HTTP 响应中生成指标,包括状态码和响应统计信息。
引入于: Telegraf v0.12.1 标签: server 操作系统支持: all
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
Secret-store 支持
此插件支持从 secret-stores 获取 username 和 password 选项的密钥。有关如何使用它们的更多详细信息,请参阅 secret-store 文档。
配置
# HTTP/HTTPS request given an address a method and a timeout
[[inputs.http_response]]
## List of urls to query.
# urls = ["https://"]
## Set http_proxy.
## Telegraf uses the system wide proxy settings if it's is not set.
# http_proxy = "https://:8888"
## Set response_timeout (default 5 seconds)
# response_timeout = "5s"
## HTTP Request Method
# method = "GET"
## Whether to follow redirects from the server (defaults to false)
# follow_redirects = false
## Optional file with Bearer token
## file content is added as an Authorization header
# bearer_token = "/path/to/file"
## Optional HTTP Basic Auth Credentials
# username = "username"
# password = "pa$$word"
## Optional HTTP Request Body
# body = '''
# {'fake':'data'}
# '''
## Optional HTTP Request Body Form
## Key value pairs to encode and set at URL form. Can be used with the POST
## method + application/x-www-form-urlencoded content type to replicate the
## POSTFORM method.
# body_form = { "key": "value" }
## Optional name of the field that will contain the body of the response.
## By default it is set to an empty String indicating that the body's
## content won't be added
# response_body_field = ''
## Maximum allowed HTTP response body size in bytes.
## 0 means to use the default of 32MiB.
## If the response body size exceeds this limit a "body_read_error" will
## be raised.
# response_body_max_size = "32MiB"
## Optional substring or regex match in body of the response (case sensitive)
# response_string_match = "\"service_status\": \"up\""
# response_string_match = "ok"
# response_string_match = "\".*_status\".?:.?\"up\""
## Expected response status code.
## The status code of the response is compared to this value. If they match,
## the field "response_status_code_match" will be 1, otherwise it will be 0.
## If the expected status code is 0, the check is disabled and the field
## won't be added.
# response_status_code = 0
## 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
## Use the given name as the SNI server name on each URL
# tls_server_name = ""
## TLS renegotiation method, choose from "never", "once", "freely"
# tls_renegotiation_method = "never"
## HTTP Request Headers (all values must be strings)
# [inputs.http_response.headers]
# Host = "github.com"
## Optional setting to map response http headers into tags
## If the http header is not present on the request, no corresponding tag will
## be added. If multiple instances of the http header are present, only the
## first value will be used.
# http_header_tags = {"HTTP_HEADER" = "TAG_NAME"}
## Interface to use when dialing an address
# interface = "eth0"
## Optional Cookie authentication
# cookie_auth_url = "https:///authMe"
# cookie_auth_method = "POST"
# cookie_auth_username = "username"
# cookie_auth_password = "pa$$word"
# cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}'
## cookie_auth_renewal not set or set to "0" will auth once and never renew the cookie
# cookie_auth_renewal = "5m"Metrics
- http_response
- 标签 (tags)
- server (目标 URL)
- method (请求方法)
- status_code (响应状态码)
- result (见下文
- result_code (int, 见下文将触发此错误。或者使用了
response_body_field选项,但响应体内容不是有效的 utf-8。或者响应体的大小超过了response_body_max_size| |connection_failed | 3 |捕获所有未被插件专门处理的网络错误| |timeout | 4 |插件在等待 HTTP 连接完成时超时| |dns_error | 5 |尝试连接主机时发生 DNS 错误| |response_status_code_mismatch | 6 |使用了response_status_code_match选项,但响应的状态码与指定值不匹配。|
- 标签 (tags)
示例输出
http_response,method=GET,result=success,server=http://github.com,status_code=200 content_length=87878i,http_response_code=200i,response_time=0.937655534,result_code=0i,result_type="success" 1565839598000000000可选 Cookie 身份验证设置
可选的 Cookie 身份验证设置将从给定的授权端点检索 Cookie,并在后续的 API 请求中使用它。这对于不提供 OAuth 或 Basic Auth 身份验证的服务很有用,例如 Tesla Powerwall API,它使用 Cookie Auth Body 来检索授权 Cookie。Cookie Auth Renewal 间隔将以给定的间隔续订授权,通过检索新的 Cookie。
此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。