我正在使用inputs.http_response模块来监视某些URL的状态。实际上,只有一个URL,因为当我添加更多URL时,它会停止监视(并且,实际上,在telegraf启动时会退出并注意到配置错误)。
这是我尝试过的两个例子:
[[inputs.http_response]]
address = "https://www.example.com/index.html"
response_timeout = "5s"
method = "GET"
follow_redirects = false
[[inputs.http_response]]
address = "https://blog.example.com/index.html"
response_timeout = "5s"
method = "GET"
follow_redirects = false
并且
[[inputs.http_response]]
address = ["https://www.example.com/index.html", "https://blog.example.com/index.html"]
response_timeout = "5s"
method = "GET"
follow_redirects = false
没有括号也一样。
关于如何监控多个 URL 有什么建议吗?
答案1
您必须更改 telegraf 输入配置,方法是更改输入名称。可以通过创建名称后缀、前缀甚至覆盖输入名称本身来完成 - 必须为每个新的“http_response”输入执行此操作。类似于此示例:
[[inputs.http_response]]
name_suffix = "_www"
address = "https://www.example.com/index.html"
response_timeout = "10s"
method = "GET"
follow_redirects = false
[[inputs.http_response]]
name_suffix = "_blog"
address = "https://blog.example.com/index.html"
response_timeout = "10s"
method = "GET"
follow_redirects = false
在此示例中,输入名称将变为http_response_www和http_response_blog。
更多信息请访问:https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#input-configuration