mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-22 00:35:22 +00:00
Add logging when manually changing the hc status
This commit is contained in:
@@ -22,6 +22,7 @@ import logger from "@server/logger";
|
||||
import { fromError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { addStandaloneHealthCheck } from "@server/routers/newt/targets";
|
||||
import { fireHealthCheckUnhealthyAlert } from "#private/lib/alerts";
|
||||
|
||||
const paramsSchema = z.strictObject({
|
||||
orgId: z.string().nonempty()
|
||||
@@ -146,6 +147,15 @@ export async function createHealthCheck(
|
||||
})
|
||||
.returning();
|
||||
|
||||
await fireHealthCheckUnhealthyAlert(
|
||||
record.orgId,
|
||||
record.targetHealthCheckId,
|
||||
record.name || "",
|
||||
undefined,
|
||||
undefined,
|
||||
false // dont send the alert because we just want to create the alert, not notify users yet
|
||||
);
|
||||
|
||||
// Push health check to newt if the site is a newt site
|
||||
if (siteId) {
|
||||
const [site] = await db
|
||||
|
||||
@@ -22,6 +22,7 @@ import { fromError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { and, eq, isNull } from "drizzle-orm";
|
||||
import { addStandaloneHealthCheck } from "@server/routers/newt/targets";
|
||||
import { fireHealthCheckUnhealthyAlert, fireHealthCheckUnknownAlert, fireHealthCheckHealthyAlert } from "#private/lib/alerts";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
@@ -233,6 +234,37 @@ export async function updateHealthCheck(
|
||||
)
|
||||
.returning();
|
||||
|
||||
if (updated.hcHealth === "unhealthy" && existingHealthCheck.hcHealth !== "unhealthy") {
|
||||
await fireHealthCheckUnhealthyAlert(
|
||||
updated.orgId,
|
||||
updated.targetHealthCheckId,
|
||||
updated.name || "",
|
||||
undefined,
|
||||
undefined,
|
||||
false // dont send the alert because we just want to create the alert, not notify users yet
|
||||
);
|
||||
} else if (updated.hcHealth === "unknown" && existingHealthCheck.hcHealth !== "unknown") {
|
||||
// if the health is unknown, we want to fire an alert to notify users to enable health checks
|
||||
await fireHealthCheckUnknownAlert(
|
||||
updated.orgId,
|
||||
updated.targetHealthCheckId,
|
||||
updated.name,
|
||||
undefined,
|
||||
undefined,
|
||||
false // dont send the alert because we just want to create the alert, not notify users yet
|
||||
);
|
||||
} else if (updated.hcHealth === "healthy" && existingHealthCheck.hcHealth !== "healthy") {
|
||||
await fireHealthCheckHealthyAlert(
|
||||
updated.orgId,
|
||||
updated.targetHealthCheckId,
|
||||
updated.name,
|
||||
undefined,
|
||||
undefined,
|
||||
false // dont send the alert because we just want to create the alert, not notify users yet
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Push updated health check to newt if the site is a newt site
|
||||
const [newt] = await db
|
||||
.select()
|
||||
|
||||
Reference in New Issue
Block a user