in src/main/java/co/elastic/support/diagnostics/commands/RunKibanaQueries.java [101:135]
public int runBasicQueries(RestClient client, DiagnosticContext context, List<String> spacesIds) throws DiagnosticException {
List<RestEntry> queries = new ArrayList<>();
for (Map.Entry<String, RestEntry> entry : context.elasticRestCalls.entrySet()) {
RestEntry current = entry.getValue();
if (current.isSpaceAware()) {
for (String spaceId : spacesIds) {
RestEntry restEntry = current;
// The calls made for the default Space will be written without a subpath
if (!"default".equals(spaceId)) {
String url = String.format("/s/%s%s", spaceId, restEntry.getUrl());
String subdir = Paths.get(
restEntry.getSubdir(),
"space_" + spaceId.replaceAll("[^a-zA-Z0-9-_]", "_")
).normalize().toString();
restEntry = current.copyWithNewUrl(url, subdir);
}
if (restEntry.isPageable()) {
getAllPages(client, queries, context.perPage, restEntry, current.getPageableFieldName());
} else {
queries.add(restEntry);
}
}
} else if (current.isPageable()) {
getAllPages(client, queries, context.perPage, entry.getValue(), current.getPageableFieldName());
} else {
queries.add(entry.getValue());
}
}
return runQueries(client, queries, context.tempDir, 0, 0);
}