refactor(web): 优化日志查看
This commit is contained in:
@@ -48,7 +48,7 @@ public class LokiQueryApplication {
|
||||
private final LokiQueryService lokiQueryService;
|
||||
|
||||
@GetMapping("query_range")
|
||||
public ImmutableList<LokiLogLine> queryRange(@RequestParam Map<String, String> queryMap) throws Exception {
|
||||
return lokiQueryService.queryRange(Maps.immutable.ofAll(queryMap));
|
||||
public ImmutableList<LokiLogLine> queryRange(@RequestParam Map<String, String> queryMap, @RequestParam(value = "limit", defaultValue = "200") Integer limit) throws Exception {
|
||||
return lokiQueryService.queryRange(Maps.immutable.ofAll(queryMap), limit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ public class LokiQueryService {
|
||||
}
|
||||
|
||||
@Retryable(Throwable.class)
|
||||
public ImmutableList<LokiLogLine> queryRange(ImmutableMap<String, String> queryMap) throws Exception {
|
||||
public ImmutableList<LokiLogLine> queryRange(ImmutableMap<String, String> queryMap, Integer limit) throws Exception {
|
||||
String query = URLUtil.encodeQuery(buildLokiQuery(queryMap));
|
||||
String queryUrl = StrUtil.format("{}/loki/api/v1/query_range?query={}&limit=200", lokiConfiguration.getHost(), query);
|
||||
String queryUrl = StrUtil.format("{}/loki/api/v1/query_range?query={}&limit={}", lokiConfiguration.getHost(), query, limit);
|
||||
HttpResponse response = HttpUtil.createGet(queryUrl).execute();
|
||||
if (response.isOk()) {
|
||||
LokiQueryRangeResponse queryRangeResponse = mapper.readValue(response.body(), LokiQueryRangeResponse.class);
|
||||
|
||||
Reference in New Issue
Block a user