Skip to content

Commit

Permalink
More tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Mar 29, 2021
1 parent f867de4 commit 8a6cf95
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class CcrShard extends PureComponent {
const { stat, oldestStat, formattedLeader, alerts } = this.props;

return (
<EuiPage style={{ backgroundColor: 'white' }}>
<EuiPage>
<EuiPageBody>
<EuiPanel>
<Status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
*/

import React from 'react';
import { get } from 'lodash';
import { SummaryStatus } from '../../summary_status';
import { formatMetric } from '../../../lib/format_number';
import { i18n } from '@kbn/i18n';
import { AlertsStatus } from '../../../alerts/status';

export function Status({ stat, formattedLeader, oldestStat, alerts = {} }) {
const {
follower_index: followerIndex,
shard_id: shardId,
operations_written: operationsReceived,
failed_read_requests: failedFetches,
} = stat;

const {
operations_written: oldestOperationsReceived,
failed_read_requests: oldestFailedFetches,
} = oldestStat;
const followerIndex = stat.follower_index || get(stat, 'follower.index');
const shardId = stat.shard_id || get(stat, 'follower.shard.number');
const operationsReceived = stat.operations_written || get(stat, 'follower.operations_written');
const failedFetches = stat.failed_read_requests || get(stat, 'requests.failed.read.count');
const oldestOperationsReceived =
oldestStat.operations_written || get(oldestStat, 'follower.operations_written');
const oldestFailedFetches =
oldestStat.failed_read_requests || get(oldestStat, 'requests.failed.read.count');

const metrics = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export function monitoringMlListingProvider() {
if (job.ml) {
return {
...job.ml.job,
node: job.node,
job_id: job.ml.job.id,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { ElasticsearchClient } from 'kibana/server';
import { AlertCluster, AlertClusterHealth } from '../../../common/types/alerts';
import { ElasticsearchSource } from '../../../common/types/es';
import { ElasticsearchSource, ElasticsearchResponse } from '../../../common/types/es';

export async function fetchClusterHealth(
esClient: ElasticsearchClient,
Expand Down Expand Up @@ -59,8 +59,9 @@ export async function fetchClusterHealth(
},
};

const { body: response } = await esClient.search<ElasticsearchSource>(params);
return response.hits.hits.map((hit) => {
const result = await esClient.search<ElasticsearchSource>(params);
const response: ElasticsearchResponse = result.body as ElasticsearchResponse;
return (response.hits?.hits ?? []).map((hit) => {
return {
health: hit._source!.cluster_state?.status,
clusterUuid: hit._source!.cluster_uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { ElasticsearchClient } from 'kibana/server';
import { AlertCluster, AlertVersions } from '../../../common/types/alerts';
import { ElasticsearchSource } from '../../../common/types/es';
import { ElasticsearchSource, ElasticsearchResponse } from '../../../common/types/es';

export async function fetchElasticsearchVersions(
esClient: ElasticsearchClient,
Expand Down Expand Up @@ -60,8 +60,9 @@ export async function fetchElasticsearchVersions(
},
};

const { body: response } = await esClient.search<ElasticsearchSource>(params);
return response.hits.hits.map((hit) => {
const result = await esClient.search<ElasticsearchSource>(params);
const response: ElasticsearchResponse = result.body as ElasticsearchResponse;
return (response.hits?.hits ?? []).map((hit) => {
const versions = hit._source!.cluster_stats?.nodes?.versions ?? [];
return {
versions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ import { LegacyRequest } from '../../types';
*/
export function handleResponse(response: ElasticsearchResponse) {
const hits = response.hits?.hits;
return hits?.map((hit) => hit._source.job_stats ?? hit._source.elasticsearch) ?? [];
return (
hits?.map((hit) => {
const job = hit._source.job_stats ?? hit._source.elasticsearch;
return {
...job,
node: {
...job?.node,
name: job?.node?.name ?? job?.node?.id,
},
};
}) ?? []
);
}

export function getMlJobs(req: LegacyRequest, esIndexPattern: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function getCcrStat(req: LegacyRequest, esIndexPattern: string, filters: u
'hits.hits.inner_hits.oldest.hits.hits._source.ccr_stats.operations_written',
'hits.hits.inner_hits.oldest.hits.hits._source.elasticsearch.ccr.follower.operations_written',
'hits.hits.inner_hits.oldest.hits.hits._source.ccr_stats.failed_read_requests',
'hits.hits.inner_hits.oldest.hits.hits._source.elasticsearch.ccr.follower.failed_read_requests',
'hits.hits.inner_hits.oldest.hits.hits._source.elasticsearch.ccr.requests.failed.read.count',
],
body: {
sort: [{ timestamp: { order: 'desc', unmapped_type: 'long' } }],
Expand Down

0 comments on commit 8a6cf95

Please sign in to comment.