背景:在 metricbeat收集redis日志以及系统日志、python接收请求参数 基础上进行,部分简单内容省略
1. 新增http模块的配置
#--------------------------------- HTTP Module --------------------------------- - module: http metricsets: - json # As client period: 100s hosts: ["192.168.1.110:8001"] namespace: "json_namespace" path: "/api" #body: "" #method: "GET" #username: "user" #password: "secret" #request.enabled: false #response.enabled: false #json.is_array: false #dedot.enabled: false processors: - add_fields: target: '' fields: from: http - module: http metricsets: ["server"] # As a server,only accept post requests host: "172.18.0.2" # If using metricbeat container, here is the container ip port: "8002" server.paths: - path: "/api" namespace: "server_namespace" fields: # added to the the response in root. overwrites existing fields env: "test" processors: - add_fields: target: '' fields: from: http1. 查看作为http客户端发送的请求结果
2. 查看收集到的指标监控日志
1. 发送请求
curl --header "Content-Type:application/json" -X POST --data '{"logLevel":"ERROR", "msg":"hello world"}' http://localhost:8002/api1.1 下图为通过容器启动metricbeat的操作结果
1.2 下图为直接在主机启动metricbeat的操作结果
注: 从以上操作结果可以看出,如果配置的host是ip地址,那么不能使用localhost替代,同理配置的是localhost,也不能使用ip地址替换
2. 查看收集到的指标监控日志
2.1 下图为通过容器启动metricbeat的操作结果
2.2 下图为直接在主机启动metricbeat的操作结果
到此http指标收集成功