Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES 查询条件配置的 ”ES中_source内接口名称“ ,进行流量获取时过滤条件要求包含 http method 不大合理 #17

Closed
chenhengjie123 opened this issue Jun 22, 2021 · 1 comment

Comments

@chenhengjie123
Copy link

chenhengjie123 commented Jun 22, 2021

特指此配置项:
image

不合理原因:
在录制时,com.tal.wangxiao.conan.agent.service.impl.RecordServiceImpl#getFlowByEsClientAndSaveFLow 和此参数有关的
过滤条件为 + 空格 + :

BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
                .must(QueryBuilders.wildcardQuery(url + ".keyword", method + " " + requestQuery.getApi() + "*"))
                .must(shouldQuery);

但同样在录制逻辑中,实际入库完整 request 内容的 com.tal.wangxiao.conan.agent.service.impl.RecordServiceImpl#saveFlowInDb ,查询条件变为了纯 api path ,相关逻辑:

...
String apiKey = esConditionSetting.getApi();
...
String apiName = RegexUtils.getMsgByRegex(esFlowMap.get(apiKey) + "", esConditionSetting.getApiRegex());
...
List<Api> apiList = apiRepository.findByNameAndMethod(apiName, HttpMethodConstants.valueOf(method).getValue());

这样会导致如果没有配置 "接口正则表达式" ,且保证可以过滤掉 http method ,就会导致获取到的 apiName 为类似 GET /api/case/list 的值,导致无法匹配数据库中已定义的接口,进而出现录制是成功的(条数是对的),但实际没有任何数据入库到 bss_record_result 表(因为没有匹配到任何已定义的接口),没法回放

是否可以调整为,条数的查询条件里,去掉 http method 合并到 url 的做法,而是单独多开一个查询条件,专门查 http method ?本身 es 配置里也有要求配置单独对应 http method 的字段了,应该是可以适用的

@saviorghost
Copy link
Contributor

合并在一起的考虑是nginx的accesslog中 $request变量对应的默认如此,从减少依赖的角度这样设计的,不过可能会有您提到的问题,查询条件这部分后面的大版本我们再优化下,可以让前端配置不过于复杂,也建议各位在使用中可以根据自己的需求二开这部分。
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants