add pagerduty

This commit is contained in:
Alex Holliday committed 2025-06-10 13:44:15 +08:00
1 parent c20b8c665a
commit 08875b07ec
3 files changed
+57 -16

No files matched your search

+23
View File
@@ -463,6 +463,29 @@ class NetworkService {
}
}
async requestPagerDuty({ message, routingKey, monitorUrl }) {
try {
const response = await this.axios.post(`https://events.pagerduty.com/v2/enqueue`, {
routing_key: routingKey,
event_action: "trigger",
payload: {
summary: message,
severity: "critical",
source: monitorUrl,
timestamp: new Date().toISOString(),
},
});
if (response?.data?.status !== "success") return false;
return true;
} catch (error) {
error.details = error.response?.data;
error.service = this.SERVICE_NAME;
error.method = "requestPagerDuty";
throw error;
}
}
/**
* Gets the status of a job based on its type and returns the appropriate response.
*