Skip to content

Commit

Permalink
[backend] Rework logs of ingestion managers
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien committed Jan 3, 2025
1 parent 0e8f03c commit d3a10fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions opencti-platform/opencti-graphql/src/manager/ingestionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ const rssExecutor = async (context: AuthContext, turndownService: TurndownServic
if (messages_number === 0) {
const ingestionPromise = rssDataHandler(context, httpGet, turndownService, ingestion)
.catch((e) => {
logApp.error(`[OPENCTI-MODULE] INGESTION - Error with rss handler ${ingestion.name}`);
logApp.error(e, { name: ingestion.name, context: 'RSS ingestion execution' });
logApp.warn(e, { name: ingestion.name, context: '[OPENCTI-MODULE] INGESTION - RSS ingestion execution' });

Check warning on line 271 in opencti-platform/opencti-graphql/src/manager/ingestionManager.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/ingestionManager.ts#L271

Added line #L271 was not covered by tests
});
ingestionPromises.push(ingestionPromise);
} else {
Expand Down Expand Up @@ -444,8 +443,7 @@ const taxiiExecutor = async (context: AuthContext) => {
}
const ingestionPromise = taxiiHandler(context, ingestion)
.catch((e) => {
logApp.error(`[OPENCTI-MODULE] INGESTION - Error with taxii handler ${ingestion.name}`);
logApp.error(e, { name: ingestion.name, context: 'Taxii ingestion execution' });
logApp.warn(e, { name: ingestion.name, context: '[OPENCTI-MODULE] INGESTION - Taxii ingestion execution' });

Check warning on line 446 in opencti-platform/opencti-graphql/src/manager/ingestionManager.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/ingestionManager.ts#L446

Added line #L446 was not covered by tests
});
ingestionPromises.push(ingestionPromise);
} else {
Expand Down Expand Up @@ -507,15 +505,8 @@ const csvDataHandler = async (context: AuthContext, ingestion: BasicStoreEntityI
const csvMapper = await findById(context, user, ingestion.csv_mapper_id);
const csvMapperParsed = parseCsvMapper(csvMapper);
csvMapperParsed.user_chosen_markings = ingestion.markings ?? [];

try {
const { csvLines, addedLast } = await fetchCsvFromUrl(csvMapperParsed, ingestion);
await processCsvLines(context, ingestion, csvMapperParsed, csvLines, addedLast);
} catch (e: any) {
logApp.error(`[OPENCTI-MODULE] INGESTION - Error trying to fetch csv feed for: ${ingestion.name}`);
logApp.error(e, { ingestion });
throw e;
}
const { csvLines, addedLast } = await fetchCsvFromUrl(csvMapperParsed, ingestion);
await processCsvLines(context, ingestion, csvMapperParsed, csvLines, addedLast);

Check warning on line 509 in opencti-platform/opencti-graphql/src/manager/ingestionManager.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/ingestionManager.ts#L508-L509

Added lines #L508 - L509 were not covered by tests
};

const csvExecutor = async (context: AuthContext) => {
Expand All @@ -534,8 +525,7 @@ const csvExecutor = async (context: AuthContext) => {
if (messages_number === 0) {
const ingestionPromise = csvDataHandler(context, ingestion)
.catch((e) => {
logApp.error(`[OPENCTI-MODULE] INGESTION - Error with csv handler ${ingestion.name}`);
logApp.error(e, { name: ingestion.name, context: 'CSV ingestion execution' });
logApp.warn(e, { name: ingestion.name, context: '[OPENCTI-MODULE] INGESTION - CSV ingestion execution' });

Check warning on line 528 in opencti-platform/opencti-graphql/src/manager/ingestionManager.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/ingestionManager.ts#L528

Added line #L528 was not covered by tests
});
ingestionPromises.push(ingestionPromise);
} else {
Expand Down Expand Up @@ -568,7 +558,6 @@ const ingestionHandler = async () => {
if (e.name === TYPE_LOCK_ERROR) {
logApp.info('[OPENCTI-MODULE] INGESTION - Ingestion manager already in progress by another API');
} else {
logApp.error('[OPENCTI-MODULE] INGESTION - Ingestion handlers cannot be started');
logApp.error(e, { manager: 'INGESTION_MANAGER' });
}
} finally {
Expand Down
2 changes: 1 addition & 1 deletion opencti-worker/src/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def ping(self) -> None:
self.worker_logger.debug("PingAlive running.")
self.api.query(
"""
query workingPing {
query workerPing {
about {
version
}
Expand Down

0 comments on commit d3a10fc

Please sign in to comment.