Skip to content

Commit

Permalink
Sort node versions and join into display string
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonhultgren committed May 12, 2022
1 parent 007108a commit caeb2fc
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ElasticsearchModifiedSource,
ElasticsearchLegacySource,
ElasticsearchSourceKibanaStats,
ElasticsearchMetricbeatSource,
} from '../../../common/types/es';
// @ts-ignore
import { calculateOverallStatus } from '../calculate_overall_status';
Expand Down Expand Up @@ -47,8 +48,7 @@ export function getClustersSummary(
} = cluster;

const license = cluster.license || cluster.elasticsearch?.cluster?.stats?.license;
const version =
cluster.version || (cluster.elasticsearch?.cluster?.stats?.nodes?.versions || [])[0];
const version = cluster.version || ecsFormatVersion(cluster);
const clusterUuid = cluster.cluster_uuid || cluster.elasticsearch?.cluster?.id;
const clusterStatsLegacy = cluster.cluster_stats;
const clusterStatsMB = cluster.elasticsearch?.cluster?.stats;
Expand Down Expand Up @@ -162,3 +162,9 @@ export function getClustersSummary(
};
});
}

function ecsFormatVersion(cluster: ElasticsearchMetricbeatSource) {
const versions = cluster.elasticsearch?.cluster?.stats?.nodes?.versions || [];
const sortedVersions = [...versions].sort().reverse();
return sortedVersions.join('/');
}

0 comments on commit caeb2fc

Please sign in to comment.