数据采集 采集源配置 HTTP Check 检测指标采集
HTTP Check 检测指标采集
简介
检查 http/https 链接是否可用,并将结果上报到 DataFlux 中
前置条件
- 已安装 DataKit(DataKit 安装文档)
配置
进入 DataKit 安装目录下的 conf.d/network
目录,参照其中的 http.conf.sample
编辑一个 http.conf
文件。示例如下:
[[inputs.http]]
urls = [
"http://localhost/metrics"
]
method = "GET"
[[inputs.http_response]]
urls = [
"http://localhost/metrics"
]
method = "GET"
[[inputs.inputs.httpjson]]
name = "webserver_stats"
## URL of each server in the service's cluster
servers = [
"http://localhost:9999/stats/",
"http://localhost:9998/stats/",
]
method = "GET"
配置好后,重启 DataKit 即可生效
采集指标
http_reponse
指标 | 描述 | 类型 | 单位 | Tag |
---|---|---|---|---|
response_time |
反应时间 | float | seconds | server, method, status_code, result |
content_length |
长度 | int | - | server, method, status_code, result |
response_string_match |
响应字符串匹配 | int | - | server, method, status_code, result |
http_response_code |
int | - | server, method, status_code, result |
|
result_type |
string | - | server, method, status_code, result |
|
result_code |
int | - | server, method, status_code, result |
完成对目标服务器的轮询后,插件会在 result 中寄存操作的结果,并添加一个 result_code
字段,与该标记值相对应。这个标记用来显示网络和插件错误。
标识 | 对应值 | 描述 |
---|---|---|
success |
0 | HTTP 回应已完成(即使 HTTP 代码显示报错) |
response_string_mismatch |
1 | 操作 response_string_match 已执行,但回应不能匹配正则 |
body_read_error |
2 | 操作 response_string_match 已执行,但是插件无法读取回应 |
connection_failed |
3 | 捕获所有未经插件特殊处理的网络错误 |
timeout |
4 | 等待 HTTP 链接时插件运行超时 |
dns_error |
5 | 域名错误 |