From 168d1ca24f6bfeabb277540503d140767f199c7a Mon Sep 17 00:00:00 2001 From: Damon <604821528@qq.com> Date: Mon, 20 May 2024 05:17:09 +0800 Subject: [PATCH] refactor: upload check label when monitor empty (#3661) Co-authored-by: Frank Elsinga --- server/notification-providers/flashduty.js | 13 ++++++++++--- src/lang/en.json | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/flashduty.js b/server/notification-providers/flashduty.js index 83ef27b5c..c340ed06f 100644 --- a/server/notification-providers/flashduty.js +++ b/server/notification-providers/flashduty.js @@ -62,6 +62,15 @@ class FlashDuty extends NotificationProvider { * @returns {string} Success message */ async postNotification(notification, title, body, monitorInfo, eventStatus) { + let labels = { + resource: this.genMonitorUrl(monitorInfo), + check: monitorInfo.name, + }; + if (monitorInfo.tags && monitorInfo.tags.length > 0) { + for (let tag of monitorInfo.tags) { + labels[tag.name] = tag.value; + } + } const options = { method: "POST", url: "https://api.flashcat.cloud/event/push/alert/standard?integration_key=" + notification.flashdutyIntegrationKey, @@ -71,9 +80,7 @@ class FlashDuty extends NotificationProvider { title, event_status: eventStatus || "Info", alert_key: String(monitorInfo.id) || Math.random().toString(36).substring(7), - labels: monitorInfo?.tags?.reduce((acc, item) => ({ ...acc, - [item.name]: item.value - }), { resource: this.genMonitorUrl(monitorInfo) }), + labels, } }; diff --git a/src/lang/en.json b/src/lang/en.json index aa597a5e3..d5ba62a50 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -862,7 +862,7 @@ "noGroupMonitorMsg": "Not Available. Create a Group Monitor First.", "Close": "Close", "Request Body": "Request Body", - "wayToGetFlashDutyKey": "You can go to Channel -> (Select a Channel) -> Integrations -> Add a new integration' page, add a 'Custom Event' to get a push address, copy the Integration Key in the address. For more information, please visit", + "wayToGetFlashDutyKey": "You can go to Channel -> (Select a Channel) -> Integrations -> Add a new integration' page, add a 'Uptime Kuma' to get a push address, copy the Integration Key in the address. For more information, please visit", "FlashDuty Severity": "Severity", "nostrRelays": "Nostr relays", "nostrRelaysHelp": "One relay URL per line",