Skip to content

Commit

Permalink
ignore node stats errors
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane committed Nov 10, 2024
1 parent aeb82cb commit 4683bd3
Showing 1 changed file with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,34 @@ async function getIngestPipelineState({
.filter(({ type }) => type === 'ingest_pipeline')
.map(({ id }) => id);

const [ingestPipelines, ingestPipelinesStats] = await Promise.all([
const [ingestPipelines, ingestStatsByPipeline] = await Promise.all([
esClient.ingest.getPipeline({ id: ingestPipelineIds.join(',') }, { ignore: [404] }),
esClient.nodes.stats({
metric: 'ingest',
filter_path: ingestPipelineIds.map((id) => `nodes.*.ingest.pipelines.${id}`),
}),
esClient.nodes
.stats({
metric: 'ingest',
filter_path: ingestPipelineIds.map((id) => `nodes.*.ingest.pipelines.${id}`),
})
.then((stats) => {
return reduce(
stats.nodes,
(pipelines, { ingest }) => {
forEach(ingest?.pipelines, (value: NodesIngestTotal, key: string) => {
if (!pipelines[key]) {
pipelines[key] = { count: 0, failed: 0 };
}
pipelines[key].count += value.count ?? 0;
pipelines[key].failed += value.failed ?? 0;
});
return pipelines;
},
{} as Record<string, { count: number; failed: number }>
);
})
.catch(() => {
return {} as Record<string, { count: number; failed: number }>;
}),
]);

const ingestStatsByPipeline = reduce(
ingestPipelinesStats.nodes,
(pipelines, { ingest }) => {
forEach(ingest?.pipelines, (value: NodesIngestTotal, key: string) => {
if (!pipelines[key]) {
pipelines[key] = { count: 0, failed: 0 };
}
pipelines[key].count += value.count ?? 0;
pipelines[key].failed += value.failed ?? 0;
});
return pipelines;
},
{} as Record<string, { count: number; failed: number }>
);

return ingestPipelineIds.map((id) => ({
id,
installed: !!ingestPipelines[id],
Expand Down

0 comments on commit 4683bd3

Please sign in to comment.