4.1 获取数据
4.1.1 告警数据
4.1.1.1 请求接口
请求方式:POST请求
URL地址: http://{ip}:{port}/api/v1/search/monitor
ip:封神ecs_ip
port:9170
PARAM:参数列表可查看文后资料[2]了解详情。
4.1.1.2 DEMO
import sys
import requests
url = "http://{ip}:{port}/api/v1/search/monitor/"
data = {"product":"MQ", "title":"积压告警", "stime":"2020-01-04 00:00:00", "etime":"2020-01-04 00:01:00"}
res = requests.post(url=url, json=data)
print res.content
curl -H "Content-Type:application/json"
-X POST -d '{"type":"ALL"}' http://{ip}:{port}/api/v1/search/monitor/
4.1.1.3 数据返回
①当前存在告警
{"code":0, "data":[{"info":"0.0.0.0,ecs,95% \n 0.0.0.1,ecs,95% ", "product":"ECS", "title":"性能告警", "level":"告警", "robot":"姜子牙", "monitor_time":"2020-01-14 00:00:00", "columns":"IP,产品,值"}]}
②当前未存在告警数据(告警恢复正常)
{"code":0, "data":[{"info":"", "product":"ECS", "title":"性能告警", "level":"告警", "robot":"姜子牙", "monitor_time":"2020-01-14 00:00:00", "columns":"IP,产品,值"}]}
③未查询到数据:
{"code":0, "data":[]}
④查询异常:
{"code":500, "data":"异常信息"}
4.1.2 全量数据
4.1.2.1 请求接口
请求方式:POST请求
URL地址: http://{ip}:{port}/api/v1/search/data/
ip:封神ecs_ip
port:9170
PARAM:参数列表可查看文后资料[2]了解详情。
4.1.2.2 DEMO
import sys
import requests
url = "http://{ip}:{port}/api/v1/search/data/"
data = {"product":"MQ", "title":"TIME", "stime":"2020-01-04 00:00:00", "etime":"2020-01-04 00:01:00"}
res = requests.post(url=url, json=data)
print res.content
4.1.2.3 数据返回
4.1.3 性能数据
4.1.3.1 请求接口
请求方式:POST请求
URL地址: http://{ip}:{port}/api/v1/influxdb_query/
ip:封神ecs_ip
port:9170
PARAM:参数为INFLUXDB SQL
4.1.3.2 DEMO
import sys