Skip to content

Commit

Permalink
Replace monitorJSON.name with monitorJSON.pathName in all notificatio…
Browse files Browse the repository at this point in the history
…n providers (where applicable)

As noted in louislam#3798, it would be great to have the alarm notification include
the full monitor path.  This was done for Mattermost in louislam#3801, but not for
the other notification providers.  This commit replaces all other trivial
occurences of monitorJSON.name with monitorJSON.pathName.
  • Loading branch information
SOwOphie committed Dec 30, 2024
1 parent be2faf6 commit 4f7cc5d
Show file tree
Hide file tree
Showing 24 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion server/notification-providers/alerta.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Alerta extends NotificationProvider {
correlate: [ "service_up", "service_down" ],
event: monitorJSON["type"],
group: "uptimekuma-" + monitorJSON["type"],
resource: monitorJSON["name"],
resource: monitorJSON["pathName"],
}, data );

if (heartbeatJSON["status"] === DOWN) {
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/aliyun-sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AliyunSMS extends NotificationProvider {
try {
if (heartbeatJSON != null) {
let msgBody = JSON.stringify({
name: monitorJSON["name"],
name: monitorJSON["pathName"],
time: heartbeatJSON["time"],
status: this.statusToString(heartbeatJSON["status"]),
msg: heartbeatJSON["msg"],
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/dingding.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DingDing extends NotificationProvider {
let params = {
msgtype: "markdown",
markdown: {
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}`,
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["pathName"]}`,
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["pathName"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
},
"at": {
"isAtAll": notification.mentioning === "everyone"
Expand Down
6 changes: 3 additions & 3 deletions server/notification-providers/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class Discord extends NotificationProvider {
let discorddowndata = {
username: discordDisplayName,
embeds: [{
title: "❌ Your service " + monitorJSON["name"] + " went down. ❌",
title: "❌ Your service " + monitorJSON["pathName"] + " went down. ❌",
color: 16711680,
timestamp: heartbeatJSON["time"],
fields: [
{
name: "Service Name",
value: monitorJSON["name"],
value: monitorJSON["pathName"],
},
{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
Expand Down Expand Up @@ -81,7 +81,7 @@ class Discord extends NotificationProvider {
fields: [
{
name: "Service Name",
value: monitorJSON["name"],
value: monitorJSON["pathName"],
},
{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/feishu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Feishu extends NotificationProvider {
header: {
title: {
tag: "plain_text",
content: "UptimeKuma Alert: [Down] " + monitorJSON["name"],
content: "UptimeKuma Alert: [Down] " + monitorJSON["pathName"],
},
template: "red",
},
Expand Down Expand Up @@ -64,7 +64,7 @@ class Feishu extends NotificationProvider {
header: {
title: {
tag: "plain_text",
content: "UptimeKuma Alert: [UP] " + monitorJSON["name"],
content: "UptimeKuma Alert: [UP] " + monitorJSON["pathName"],
},
template: "green",
},
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/google-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GoogleChat extends NotificationProvider {
if (monitorJSON && heartbeatJSON) {
chatHeader["title"] =
heartbeatJSON["status"] === UP
? `✅ ${monitorJSON["name"]} is back online`
: `🔴 ${monitorJSON["name"]} went down`;
? `✅ ${monitorJSON["pathName"]} is back online`
: `🔴 ${monitorJSON["pathName"]} went down`;
}

// always show msg
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/grafana-oncall.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class GrafanaOncall extends NotificationProvider {
return okMsg;
} else if (heartbeatJSON["status"] === DOWN) {
let grafanadowndata = {
title: monitorJSON["name"] + " is down",
title: monitorJSON["pathName"] + " is down",
message: heartbeatJSON["msg"],
state: "alerting",
};
await axios.post(notification.GrafanaOncallURL, grafanadowndata);
return okMsg;
} else if (heartbeatJSON["status"] === UP) {
let grafanaupdata = {
title: monitorJSON["name"] + " is up",
title: monitorJSON["pathName"] + " is up",
message: heartbeatJSON["msg"],
state: "ok",
};
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/home-assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HomeAssistant extends NotificationProvider {
title: "Uptime Kuma",
message: msg,
...(notificationService !== "persistent_notification" && { data: {
name: monitorJSON?.name,
name: monitorJSON?.pathName,
status: heartbeatJSON?.status,
channel: "Uptime Kuma",
icon_url: "https://github.com/louislam/uptime-kuma/blob/master/public/icon.png?raw=true",
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Line extends NotificationProvider {
{
"type": "text",
"text": "UptimeKuma Alert: [🔴 Down]\n" +
"Name: " + monitorJSON["name"] + " \n" +
"Name: " + monitorJSON["pathName"] + " \n" +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
}
Expand All @@ -51,7 +51,7 @@ class Line extends NotificationProvider {
{
"type": "text",
"text": "UptimeKuma Alert: [✅ Up]\n" +
"Name: " + monitorJSON["name"] + " \n" +
"Name: " + monitorJSON["pathName"] + " \n" +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
}
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/linenotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class LineNotify extends NotificationProvider {
} else if (heartbeatJSON["status"] === DOWN) {
let downMessage = {
"message": "\n[🔴 Down]\n" +
"Name: " + monitorJSON["name"] + " \n" +
"Name: " + monitorJSON["pathName"] + " \n" +
heartbeatJSON["msg"] + "\n" +
`Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
};
await axios.post(url, qs.stringify(downMessage), config);
} else if (heartbeatJSON["status"] === UP) {
let upMessage = {
"message": "\n[✅ Up]\n" +
"Name: " + monitorJSON["name"] + " \n" +
"Name: " + monitorJSON["pathName"] + " \n" +
heartbeatJSON["msg"] + "\n" +
`Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
};
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/lunasea.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LunaSea extends NotificationProvider {

if (heartbeatJSON["status"] === DOWN) {
let downdata = {
"title": "UptimeKuma Alert: " + monitorJSON["name"],
"title": "UptimeKuma Alert: " + monitorJSON["pathName"],
"body": "[🔴 Down] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
Expand All @@ -36,7 +36,7 @@ class LunaSea extends NotificationProvider {

if (heartbeatJSON["status"] === UP) {
let updata = {
"title": "UptimeKuma Alert: " + monitorJSON["name"],
"title": "UptimeKuma Alert: " + monitorJSON["pathName"],
"body": "[✅ Up] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/mattermost.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Mattermost extends NotificationProvider {
}

let mattermostdata = {
username: monitorJSON.name + " " + mattermostUserName,
username: monitorJSON.pathName + " " + mattermostUserName,
channel: mattermostChannel,
icon_emoji: iconEmoji,
icon_url: mattermostIconUrl,
Expand Down
6 changes: 3 additions & 3 deletions server/notification-providers/ntfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Ntfy extends NotificationProvider {
if (heartbeatJSON == null) {
let ntfyTestData = {
"topic": notification.ntfytopic,
"title": (monitorJSON?.name || notification.ntfytopic) + " [Uptime-Kuma]",
"title": (monitorJSON?.pathName || notification.ntfytopic) + " [Uptime-Kuma]",
"message": msg,
"priority": notification.ntfyPriority,
"tags": [ "test_tube" ],
Expand All @@ -52,15 +52,15 @@ class Ntfy extends NotificationProvider {
"topic": notification.ntfytopic,
"message": heartbeatJSON.msg,
"priority": priority,
"title": monitorJSON.name + " " + status + " [Uptime-Kuma]",
"title": monitorJSON.pathName + " " + status + " [Uptime-Kuma]",
"tags": tags,
};

if (monitorJSON.url && monitorJSON.url !== "https://") {
data.actions = [
{
"action": "view",
"label": "Open " + monitorJSON.name,
"label": "Open " + monitorJSON.pathName,
"url": monitorJSON.url,
},
];
Expand Down
6 changes: 3 additions & 3 deletions server/notification-providers/opsgenie.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Opsgenie extends NotificationProvider {

if (heartbeatJSON.status === DOWN) {
let data = {
"message": monitorJSON ? textMsg + `: ${monitorJSON.name}` : textMsg,
"alias": monitorJSON.name,
"message": monitorJSON ? textMsg + `: ${monitorJSON.pathName}` : textMsg,
"alias": monitorJSON.pathName,
"description": msg,
"source": "Uptime Kuma",
"priority": `P${priority}`
Expand All @@ -54,7 +54,7 @@ class Opsgenie extends NotificationProvider {
}

if (heartbeatJSON.status === UP) {
let opsgenieAlertsCloseUrl = `${opsgenieAlertsUrl}/${encodeURIComponent(monitorJSON.name)}/close?identifierType=alias`;
let opsgenieAlertsCloseUrl = `${opsgenieAlertsUrl}/${encodeURIComponent(monitorJSON.pathName)}/close?identifierType=alias`;
let data = {
"source": "Uptime Kuma",
};
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/pushbullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Pushbullet extends NotificationProvider {
} else if (heartbeatJSON["status"] === DOWN) {
let downData = {
"type": "note",
"title": "UptimeKuma Alert: " + monitorJSON["name"],
"title": "UptimeKuma Alert: " + monitorJSON["pathName"],
"body": "[🔴 Down] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
Expand All @@ -39,7 +39,7 @@ class Pushbullet extends NotificationProvider {
} else if (heartbeatJSON["status"] === UP) {
let upData = {
"type": "note",
"title": "UptimeKuma Alert: " + monitorJSON["name"],
"title": "UptimeKuma Alert: " + monitorJSON["pathName"],
"body": "[✅ Up] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/pushdeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class PushDeer extends NotificationProvider {

let title;
if (valid && heartbeatJSON.status === UP) {
title = "## Uptime Kuma: " + monitorJSON.name + " up";
title = "## Uptime Kuma: " + monitorJSON.pathName + " up";
} else if (valid && heartbeatJSON.status === DOWN) {
title = "## Uptime Kuma: " + monitorJSON.name + " down";
title = "## Uptime Kuma: " + monitorJSON.pathName + " down";
} else {
title = "## Uptime Kuma Message";
}
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/serverchan.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ServerChan extends NotificationProvider {
checkStatus(heartbeatJSON, monitorJSON) {
let title = "UptimeKuma Message";
if (heartbeatJSON != null && heartbeatJSON["status"] === UP) {
title = "UptimeKuma Monitor Up " + monitorJSON["name"];
title = "UptimeKuma Monitor Up " + monitorJSON["pathName"];
}
if (heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
title = "UptimeKuma Monitor Down " + monitorJSON["name"];
title = "UptimeKuma Monitor Down " + monitorJSON["pathName"];
}
return title;
}
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/sevenio.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class SevenIO extends NotificationProvider {

// If heartbeatJSON is not null, we go into the normal alerting loop.
if (heartbeatJSON["status"] === DOWN) {
data.text = `Your service ${monitorJSON["name"]} ${address}went down at ${heartbeatJSON["localDateTime"]} ` +
data.text = `Your service ${monitorJSON["pathName"]} ${address}went down at ${heartbeatJSON["localDateTime"]} ` +
`(${heartbeatJSON["timezone"]}). Error: ${heartbeatJSON["msg"]}`;
} else if (heartbeatJSON["status"] === UP) {
data.text = `Your service ${monitorJSON["name"]} ${address}went back up at ${heartbeatJSON["localDateTime"]} ` +
data.text = `Your service ${monitorJSON["pathName"]} ${address}went back up at ${heartbeatJSON["localDateTime"]} ` +
`(${heartbeatJSON["timezone"]}).`;
}
await axios.post("sms", data, config);
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/smtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SMTP extends NotificationProvider {
let monitorHostnameOrURL = "testing.hostname";

if (monitorJSON !== null) {
monitorName = monitorJSON["name"];
monitorName = monitorJSON["pathName"];
monitorHostnameOrURL = this.extractAddress(monitorJSON);
}

Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/squadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Squadcast extends NotificationProvider {
data.event_id = heartbeatJSON["monitorID"];

if (heartbeatJSON["status"] === DOWN) {
data.message = `${monitorJSON["name"]} is DOWN`;
data.message = `${monitorJSON["pathName"]} is DOWN`;
data.status = "trigger";
} else {
data.message = `${monitorJSON["name"]} is UP`;
data.message = `${monitorJSON["pathName"]} is UP`;
data.status = "resolve";
}

Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/stackfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Stackfield extends NotificationProvider {

let textMsg = "+Uptime Kuma Alert+";

if (monitorJSON && monitorJSON.name) {
textMsg += `\n*${monitorJSON.name}*`;
if (monitorJSON && monitorJSON.pathName) {
textMsg += `\n*${monitorJSON.pathName}*`;
}

textMsg += `\n${msg}`;
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Teams extends NotificationProvider {

const payload = this._notificationPayloadFactory({
heartbeatJSON: heartbeatJSON,
monitorName: monitorJSON.name,
monitorName: monitorJSON.pathName,
monitorUrl: this.extractAddress(monitorJSON),
dashboardUrl: dashboardUrl,
});
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/wpush.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class WPush extends NotificationProvider {
checkStatus(heartbeatJSON, monitorJSON) {
let title = "UptimeKuma Message";
if (heartbeatJSON != null && heartbeatJSON["status"] === UP) {
title = "UptimeKuma Monitor Up " + monitorJSON["name"];
title = "UptimeKuma Monitor Up " + monitorJSON["pathName"];
}
if (heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
title = "UptimeKuma Monitor Down " + monitorJSON["name"];
title = "UptimeKuma Monitor Down " + monitorJSON["pathName"];
}
return title;
}
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/zoho-cliq.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ZohoCliq extends NotificationProvider {

const payload = this._notificationPayloadFactory({
monitorMessage: heartbeatJSON.msg,
monitorName: monitorJSON.name,
monitorName: monitorJSON.pathName,
monitorUrl: this.extractAddress(monitorJSON),
status: heartbeatJSON.status
});
Expand Down

0 comments on commit 4f7cc5d

Please sign in to comment.