Skip to content

Commit

Permalink
More verbose debugging of writing our anomalies
Browse files Browse the repository at this point in the history
Something's happening within es_archiver, and I'm trying to figure out
what.
  • Loading branch information
rylnd committed May 3, 2024
1 parent 21d2c59 commit bdab2be
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,34 @@ export function createIndexDocRecordsStream(
const operation = useCreate === true ? BulkOperation.Create : BulkOperation.Index;
const ops = new WeakMap<any, any>();
const errors: string[] = [];
let isRelevant = false;
const datasource = docs.map((doc) => {
const body = doc.source;
const op = doc.data_stream ? BulkOperation.Create : operation;
const index = doc.data_stream || doc.index;
if (index.startsWith('.ml-anomalies-custom')) {
isRelevant = true;
}

ops.set(body, {
[op]: {
_index: index,
_id: doc.id,
},
});
return body;
});

if (isRelevant) {
console.log('datasource:', JSON.stringify(datasource, null, 2));
console.log('ops:', JSON.stringify(ops, null, 2));
}

await client.helpers.bulk(
{
retries: 5,
concurrency: performance?.concurrency || DEFAULT_PERFORMANCE_OPTIONS.concurrency,
datasource: docs.map((doc) => {
const body = doc.source;
const op = doc.data_stream ? BulkOperation.Create : operation;
const index = doc.data_stream || doc.index;
ops.set(body, {
[op]: {
_index: index,
_id: doc.id,
},
});
return body;
}),
datasource,
onDocument(doc) {
return ops.get(doc);
},
Expand Down

0 comments on commit bdab2be

Please sign in to comment.