From 0890660e011484dd7cccc3122dba0009c30cd85c Mon Sep 17 00:00:00 2001 From: Sid Sun Date: Fri, 9 May 2025 08:43:10 +1000 Subject: [PATCH] Prepend hostname to notification message If multiple instances of uptime-kuma are deployed to cross-check each other and/or in different environments (say ipv4+ipv6 and ipv6 only), and only one or some of the instances fire notificationsm, it is tricky to figure out which specific environment is experiencing the outage. Explicitly setting unique hostnames and prepending it to the message will help in these scenarios. Signed-off-by: Sid Sun --- README.md | 4 ++-- compose.yaml | 1 + server/model/monitor.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 34e34020f..02392c230 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ It is a temporary live demo, all data will be deleted after 10 minutes. Sponsore ### 🐳 Docker ```bash -docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1 +docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --hostname uptime-kuma --name uptime-kuma louislam/uptime-kuma:1 ``` Uptime Kuma is now running on . @@ -52,7 +52,7 @@ Uptime Kuma is now running on . > If you want to limit exposure to localhost (without exposing port for other users or to use a [reverse proxy](https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy)), you can expose the port like this: > > ```bash -> docker run -d --restart=always -p 127.0.0.1:3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1 +> docker run -d --restart=always -p 127.0.0.1:3001:3001 -v uptime-kuma:/app/data --hostname uptime-kuma --name uptime-kuma louislam/uptime-kuma:1 > ``` ### 💪🏻 Non-Docker diff --git a/compose.yaml b/compose.yaml index 004705a63..42fb50d65 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,5 +1,6 @@ services: uptime-kuma: + hostname: uptime-kuma image: louislam/uptime-kuma:1 volumes: - ./data:/app/data diff --git a/server/model/monitor.js b/server/model/monitor.js index 58decbcba..92afb5c73 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -24,6 +24,7 @@ const { CookieJar } = require("tough-cookie"); const { HttpsCookieAgent } = require("http-cookie-agent/http"); const https = require("https"); const http = require("http"); +const os = require('os'); const rootCertificates = rootCertificatesFingerprints(); @@ -1288,7 +1289,7 @@ class Monitor extends BeanModel { text = "🔴 Down"; } - let msg = `[${monitor.name}] [${text}] ${bean.msg}`; + let msg = `[${os.hostname()}] [${monitor.name}] [${text}] ${bean.msg}`; for (let notification of notificationList) { try {