Skip to content

Commit

Permalink
catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 28, 2024
1 parent ccb6e3e commit b206819
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,22 @@ ${inputsYaml}
const MAX_ITERATIONS = 20;
let foundMetrics = false;
for (let i = 0; i < MAX_ITERATIONS; i++) {
const searchRes = await es.search({
index: 'metrics-system.cpu-default',
q: `agent.name:${agent.name}`,
ignore_unavailable: true,
});

// @ts-expect-error TotalHit
if (searchRes.hits.total.value > 0) {
foundMetrics = true;
break;
try {
const searchRes = await es.search({
index: 'metrics-system.cpu-default',
q: `agent.name:${agent.name}`,
ignore_unavailable: true,
});

// @ts-expect-error TotalHit
if (searchRes.hits.total.value > 0) {
foundMetrics = true;
break;
}
} catch (err) {
log.error(err);
}

// await agent.log(); uncomment if you need to debug agent logs
await new Promise((resolve) => setTimeout(resolve, 5 * 1000));
}
Expand Down

0 comments on commit b206819

Please sign in to comment.