Skip to content

Commit

Permalink
fix: update PD alert custom details
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Jun 30, 2024
1 parent a0f4292 commit 2f16322
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/backend/src/services/runtime-analysis/PagerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
const pdjs = require('@pagerduty/pdjs');
const BaseService = require('../BaseService');
const util = require('util');
const { Context } = require('../../util/context');

class PagerService extends BaseService {
async _construct () {
Expand Down Expand Up @@ -50,6 +51,26 @@ class PagerService extends BaseService {
fields_clean[key] = util.inspect(value);
}

const custom_details = {
...(alert.custom || {}),
server_id: this.global_config.server_id,
};

const ctx = Context.get(undefined, { allow_fallback: true });

// Add request payload if any exists
const req = ctx.get('req');
if ( req ) {
if ( req.body ) {
// Remove fields which may contain sensitive information
delete req.body.password;
delete req.body.email;

// Add the request body to the custom details
custom_details.request_body = req.body;
}
}

this.log.info('it is sending to PD');
await event({
data: {
Expand All @@ -60,7 +81,7 @@ class PagerService extends BaseService {
summary: alert.message,
source: alert.source,
severity: alert.severity,
custom_details: alert.custom,
custom_details,
},
},
});
Expand Down

0 comments on commit 2f16322

Please sign in to comment.