diff --git a/README.md b/README.md index a24ea37597e0ec6e433d3dee2e86dd6eb345867d..46afd5d1506e462096d03baa9f8d1f6bf17646c8 100644 --- a/README.md +++ b/README.md @@ -524,6 +524,7 @@ gala-ops针对应用异常,具备2种根因定位能力:**单节点、跨节 # 常用API介绍 +1. gala-anteater/gala-inference [rest接口使用说明](./gala_event_api.md)。 # 用户案例 diff --git a/gala_event_api.md b/gala_event_api.md new file mode 100644 index 0000000000000000000000000000000000000000..16d0b0901343ab38f0bf687937af903f7f6f4c80 --- /dev/null +++ b/gala_event_api.md @@ -0,0 +1,212 @@ +# 异常检测&根因定位数据ArangoDB接口使用指导 +异常检测、根因定位结果数据默认输出到kafka中,由其它子系统订阅消费使用。本文档提供另外一种数据对接方式,指导将kafka中的数据实时同步到ArangoDB中,其它子系统可以直接使用ArangoDB的接口获取异常检测、根因定位的数据。 + +本数据对接方案的原理,通过开源数据采集工具logstash将kafka中的数据实时消费并转存到ArangoDB中。 + +## 1. ArangoDB环境准备 +ArangoDB的安装部署参考[官网](https://www.arangodb.com/),详细过程略。下面介绍创建异常检测&根因定位对应的db和collection。 + +### 1.1 db创建 +``` +shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://ip:8529/_api/database < curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://ip:8529/_db/gala_event/_api/collection < "ip:9092" + topics => ["gala_anteater"] + group_id => "gala_group" + client_id => "gala_client" + decorate_events => "true" + } +} + +filter { + json { + source => "message" + } + + date { + match => ["Timestamp", "UNIX_MS"] + target => "@timestamp" + } + +} + +output { + stdout { codec => rubydebug } + + http { + http_method => "post" + url => "http://ip:8529/_db/gala_event/_api/document?collection=gala_event_anteater" + format => "json" + } +} +``` +### 2.3 启动运行 +``` +bin/logstash -f config/kafka_to_arangodb.conf +``` + +或者以后台服务的方式运行: +``` +bin/logstash -f config/kafka_to_arangodb.conf -d +``` + +## 3. 数据获取接口 +### 3.1 接口描述 + +Arangodb 提供的 AQL 语句查询接口,详细的 API 定义参见 arangodb 官方文档: [AQL查询接口](https://www.arangodb.com/docs/stable/http/aql-query-cursor-accessing-cursors.html)。 + +### 3.2 请求方法 + +`POST /_api/cursor` + +### 3.3 输入参数 + +**请求体**: + +`query`(string类型,必选):包含要执行的查询字符串,这里它的内容为 `"FOR t IN gala_event_anteater LIMIT 10 RETURN t"` 。 + +### 3.4 输出参数 + +**HTTP 201**:请求成功时的响应码,返回内容包括, + +- `error`(boolean类型):发生错误时标记为 true +- `code`(integer类型):HTTP 状态码 +- `result`(数组类型):返回内容,这里只返回一个元素,它的值为拓扑图的时间戳。 + +### 3.5 请求示例 +``` +curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://ip:8529/_db/gala_event/_api/cursor <