Skip to content

Commit

Permalink
Add Kafka message to success log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
marleystipich2 committed Jul 22, 2024
1 parent 9a2289a commit 1f99a0f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/handlers/advisor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default async function onMessage (message: Message) {
probes.advisorIssueUnknown(host_id, issues);
}

probes.advisorUpdateSuccess(host_id, issues, 2); // TODO: Fix Probes
probes.advisorUpdateSuccess(message, host_id, issues, 2); // TODO: Fix Probes
} catch (e) {
if (e instanceof Error) {
probes.advisorUpdateError(host_id, issues, e);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/compliance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default async function onMessage (message: Message) {
probes.complianceIssueUnknown(host_id, issues);
}

probes.complianceUpdateSuccess(host_id, issues, 2); // TODO: Fix Probes
probes.complianceUpdateSuccess(message, host_id, issues, 2); // TODO: Fix Probes
} catch (e) {
if (e instanceof Error) {
probes.complianceUpdateError(host_id, issues, e);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/patch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default async function onMessage (message: Message) {
probes.patchIssueUnknown(host_id, issues);
}

probes.patchUpdateSuccess(host_id, issues, 2); // TODO: Fix Probes
probes.patchUpdateSuccess(message, host_id, issues, 2); // TODO: Fix Probes
} catch (e) {
if (e instanceof Error) {
probes.patchUpdateError(host_id, issues, e);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/vulnerability/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default async function onMessage (message: Message) {
probes.vulnerabilityIssueUnknown(host_id, issues);
}

probes.vulnerabilityUpdateSuccess(host_id, issues, 2); // TODO: Fix Probes
probes.vulnerabilityUpdateSuccess(message, host_id, issues, 2); // TODO: Fix Probes
} catch (e) {
if (e instanceof Error) {
probes.vulnerabilityUpdateError(host_id, issues, e);
Expand Down
17 changes: 9 additions & 8 deletions src/probes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const counters = {

export function incomingMessage (topic: string, message: Message) {
log.trace({ message }, 'incoming message');
log.info({ message }, 'incoming message');
counters.incoming.labels(topic).inc();
};

Expand Down Expand Up @@ -98,8 +99,8 @@ export function lostUpdateMessage (message: ReceptorMessage<PlaybookRunUpdate>)
counters.lostMessage.inc()
}

export function advisorUpdateSuccess (host_id: string, issues: string[], references: number) {
log.info({ host_id, references }, 'advisor issues successfully updated');
export function advisorUpdateSuccess (message: Message, host_id: string, issues: string[], references: number) {
log.info({ message, host_id, references }, 'advisor issues successfully updated');
log.debug({ issues }, 'updated advisor issues');
counters.advisor.labels('success').inc();
};
Expand All @@ -124,8 +125,8 @@ export function advisorUpdateErrorParse (message: Message, err: Error) {
counters.compliance.labels('error_parse').inc();
};

export function complianceUpdateSuccess (host_id: string, issues: string[], references: number) {
log.info({ host_id, references }, 'compliance issues successfully updated');
export function complianceUpdateSuccess (message: Message, host_id: string, issues: string[], references: number) {
log.info({ message, host_id, references }, 'compliance issues successfully updated');
log.debug({ issues }, 'updated compliance issues');
counters.compliance.labels('success').inc();
};
Expand All @@ -150,8 +151,8 @@ export function complianceUpdateErrorParse (message: Message, err: Error) {
counters.compliance.labels('error_parse').inc();
};

export function patchUpdateSuccess (host_id: string, issues: string[], references: number) {
log.info({ host_id, references }, 'patch issues successfully updated');
export function patchUpdateSuccess (message: Message, host_id: string, issues: string[], references: number) {
log.info({ message, host_id, references }, 'patch issues successfully updated');
log.debug({ issues }, 'updated patch issues')
counters.patch.labels('success').inc();
};
Expand All @@ -176,8 +177,8 @@ export function patchUpdateErrorParse (message: Message, err: Error) {
counters.patch.labels('error_parse').inc();
};

export function vulnerabilityUpdateSuccess (host_id: string, issues: string[], references: number) {
log.info({ host_id, references }, 'vulnerability issues successfully updated');
export function vulnerabilityUpdateSuccess (message: Message, host_id: string, issues: string[], references: number) {
log.info({ message, host_id, references }, 'vulnerability issues successfully updated');
log.debug({ issues }, 'updated vulnerabilitiy issues');
counters.vulnerability.labels('success').inc();
};
Expand Down

0 comments on commit 1f99a0f

Please sign in to comment.