[Monitoring] Get ready for hits total format change (#26442)
* Update the specific places we care about hits.total * PR feedback * Fix test
This commit is contained in:
parent
c91ec0d1ef
commit
c37cf1eab2
|
@ -11,7 +11,6 @@ describe('get_last_recovery', () => {
|
|||
// Note: times are from the epoch!
|
||||
const resp = {
|
||||
hits: {
|
||||
total: 1, // We expect either 0 or 1; never more.
|
||||
hits: [
|
||||
{
|
||||
_source: {
|
||||
|
@ -48,7 +47,7 @@ describe('get_last_recovery', () => {
|
|||
|
||||
it('No hits results in an empty array', () => {
|
||||
// Note: we don't expect it to touch hits without total === 1
|
||||
expect(handleLastRecoveries({ hits: { total: 0 } }, new Date(0))).to.have.length(0);
|
||||
expect(handleLastRecoveries({ hits: { hits: [] } }, new Date(0))).to.have.length(0);
|
||||
});
|
||||
|
||||
it('Filters on stop time', () => {
|
||||
|
|
|
@ -36,7 +36,7 @@ export function filterOldShardActivity(startMs) {
|
|||
* @returns {Object[]} An array of shards representing active shard activity from {@code _source.index_recovery.shards}.
|
||||
*/
|
||||
export function handleLastRecoveries(resp, start) {
|
||||
if (resp.hits.total >= 1) {
|
||||
if (resp.hits.hits.length === 1) {
|
||||
const data = _.get(resp.hits.hits[0], '_source.index_recovery.shards', []).filter(filterOldShardActivity(start.getTime()));
|
||||
data.sort((a, b) => b.start_time_in_millis - a.start_time_in_millis);
|
||||
return data;
|
||||
|
|
|
@ -78,7 +78,6 @@ export async function getNodes(req, esIndexPattern, clusterStats, shardStats) {
|
|||
sort: [ { timestamp: { order: 'desc' } } ]
|
||||
},
|
||||
filterPath: [
|
||||
'hits.total',
|
||||
'hits.hits._source.source_node',
|
||||
'aggregations.nodes.buckets.key',
|
||||
...LISTING_METRICS_PATHS,
|
||||
|
|
|
@ -18,7 +18,7 @@ import { LISTING_METRICS_NAMES } from './nodes_listing_metrics';
|
|||
* @return {Array} node info combined with metrics for each node
|
||||
*/
|
||||
export function handleResponse(response, clusterStats, shardStats, timeOptions = {}) {
|
||||
if (!get(response, 'hits.total')) {
|
||||
if (!get(response, 'hits.hits')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,9 @@ export function handleResponse(resp, includeNodes, includeIndices, cluster) {
|
|||
let indicesTotals;
|
||||
let nodes;
|
||||
|
||||
if (resp && resp.hits && resp.hits.total !== 0) {
|
||||
indices = resp.aggregations.indices.buckets.reduce(normalizeIndexShards, {});
|
||||
const buckets = get(resp, 'aggregations.indices.buckets');
|
||||
if (buckets && buckets.length !== 0) {
|
||||
indices = buckets.reduce(normalizeIndexShards, {});
|
||||
indicesTotals = calculateIndicesTotals(indices);
|
||||
|
||||
if (includeNodes) {
|
||||
|
|
Loading…
Reference in a new issue