Get endpoint list order by timestamp desc (#12535)

This commit is contained in:
mrproliu 2024-08-15 16:37:34 +08:00 committed by GitHub
parent 85b03402e4
commit c1a4dc91f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View File

@ -50,6 +50,7 @@
* Fix CounterWindow concurrent increase cause NPE by PriorityQueue
* Fix format the endpoint name with empty string.
* Support async query for the composite GraphQL query.
* Get endpoint list order by timestamp desc.
#### UI

View File

@ -25,6 +25,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.skywalking.banyandb.v1.client.AbstractCriteria;
import org.apache.skywalking.banyandb.v1.client.AbstractQuery;
import org.apache.skywalking.banyandb.v1.client.DataPoint;
import org.apache.skywalking.banyandb.v1.client.MeasureQuery;
import org.apache.skywalking.banyandb.v1.client.MeasureQueryResponse;
@ -185,6 +186,7 @@ public class BanyanDBMetadataQueryDAO extends AbstractBanyanDBDAO implements IMe
if (StringUtil.isNotEmpty(serviceId)) {
query.and(eq(EndpointTraffic.SERVICE_ID, serviceId));
}
query.setOrderBy(new AbstractQuery.OrderBy(AbstractQuery.Sort.DESC));
}
});

View File

@ -29,6 +29,7 @@ import org.apache.skywalking.library.elasticsearch.requests.search.Query;
import org.apache.skywalking.library.elasticsearch.requests.search.RangeQueryBuilder;
import org.apache.skywalking.library.elasticsearch.requests.search.Search;
import org.apache.skywalking.library.elasticsearch.requests.search.SearchBuilder;
import org.apache.skywalking.library.elasticsearch.requests.search.Sort;
import org.apache.skywalking.library.elasticsearch.response.search.SearchHit;
import org.apache.skywalking.library.elasticsearch.response.search.SearchResponse;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
@ -234,7 +235,10 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
query.must(Query.term(IndexController.LogicIndicesRegister.METRIC_TABLE_NAME, EndpointTraffic.INDEX_NAME));
}
final var search = Search.builder().query(query).size(limit);
final var search = Search.builder().query(query).size(limit).sort(
EndpointTraffic.TIME_BUCKET,
Sort.Order.DESC
);
final var scroller = ElasticSearchScroller
.<Endpoint>builder()

View File

@ -223,6 +223,7 @@ public class JDBCMetadataQueryDAO implements IMetadataQueryDAO {
sql.append(" and ").append(EndpointTraffic.NAME).append(" like concat('%',?,'%') ");
condition.add(keyword);
}
sql.append(" order by ").append(EndpointTraffic.TIME_BUCKET).append(" desc");
sql.append(" limit ").append(limit);
results.addAll(