Skip to content

Open-source status page, incident response and uptime monitoring

🐛 notification not triggered (#437)

Thibault Le Ouay69116196bddd
diff --git a/apps/server/src/checker/checker.ts b/apps/server/src/checker/checker.ts
index aab413440..335faa572 100644
--- a/apps/server/src/checker/checker.ts
+++ b/apps/server/src/checker/checker.ts
@@ -1,4 +1,4 @@
-import { updateMonitorStatus } from "./alerting";
+import { triggerAlerting, updateMonitorStatus } from "./alerting";
import type { PublishPingType } from "./ping";
import { pingEndpoint, publishPing } from "./ping";
import type { Payload } from "./schema";
@@ -78,6 +78,7 @@ const run = async (data: Payload, retry?: number | undefined) => {
monitorId: data.monitorId,
status: "error",
});
+ await triggerAlerting({ monitorId: data.monitorId });
}
}
}
diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts
index 6eae274c2..9da02d8a8 100644
--- a/apps/server/src/checker/index.ts
+++ b/apps/server/src/checker/index.ts
@@ -15,7 +15,6 @@ export const checkerRoute = new Hono<{ Variables: Variables }>();
checkerRoute.post("/checker", async (c) => {
const json = await c.req.json();
-
const auth = c.req.header("Authorization");
if (auth !== `Basic ${env.CRON_SECRET}`) {
console.error("Unauthorized");
diff --git a/apps/server/src/utils/random-promise.ts b/apps/server/src/utils/random-promise.ts
index 229328af5..7fdfb6933 100644
--- a/apps/server/src/utils/random-promise.ts
+++ b/apps/server/src/utils/random-promise.ts
@@ -2,7 +2,7 @@ export function fakePromiseWithRandomResolve() {
return new Promise((resolve, reject) => {
const randomTime = Math.floor(Math.random() * 1000);
setTimeout(() => {
- const shouldResolve = Math.random() < 0; // 0.5
+ const shouldResolve = Math.random() < 1; // 0.5
if (shouldResolve) {
resolve("Promise resolved successfully.");
} else {
diff --git a/apps/server/src/v1/incidentUpdate.ts b/apps/server/src/v1/incidentUpdate.ts
index 99dc32af3..bc7a69197 100644
--- a/apps/server/src/v1/incidentUpdate.ts
+++ b/apps/server/src/v1/incidentUpdate.ts
@@ -18,7 +18,7 @@ const ParamsSelectSchema = z.object({
.min(1)
.openapi({
param: {
- name: "incidentId",
+ name: "id",
in: "path",
},
description: "The id of the update",
diff --git a/utils/api-bruno/checker.bru b/utils/api-bruno/checker.bru
new file mode 100644
index 000000000..e61d91382
--- /dev/null
+++ b/utils/api-bruno/checker.bru
@@ -0,0 +1,41 @@
+meta {
+ name: checker
+ type: http
+ seq: 2
+}
+
+post {
+ url: {{url}}/checker
+ body: text
+ auth: none
+}
+
+headers {
+ Authorization: Basic test
+ X-CloudTasks-TaskRetryCount: 1
+ Content-Type: application/json
+}
+
+body:json {
+ {
+ "workspaceId": 1,
+ "monitorId": 1,
+ "method": "GET",
+ "url":"https://openstat.us/404",
+ "status": "active",
+ "cronTimestamp":1699088595307
+ "pageIds":["1"]
+ }
+}
+
+body:text {
+ {
+ "workspaceId": "1",
+ "monitorId": "1",
+ "method": "GET",
+ "url":"https://openstat.us/404",
+ "status": "active",
+ "cronTimestamp":1699088595307,
+ "pageIds":["1"]
+ }
+}