feat(api hits): added in api hits for monitoring
This commit is contained in:
@@ -18,6 +18,11 @@ import { setupSocketIORoutes } from "./socket.io/serverSetup.js";
|
|||||||
import { serversChecks } from "./system/serverData.controller.js";
|
import { serversChecks } from "./system/serverData.controller.js";
|
||||||
import { baseSettingValidationCheck } from "./system/settingsBase.controller.js";
|
import { baseSettingValidationCheck } from "./system/settingsBase.controller.js";
|
||||||
import { startTCPServer } from "./tcpServer/tcp.server.js";
|
import { startTCPServer } from "./tcpServer/tcp.server.js";
|
||||||
|
import {
|
||||||
|
aggregateRouteHitsForBusinessDay,
|
||||||
|
cleanupOldRouteHits,
|
||||||
|
runRouteHitAnalyticsCron,
|
||||||
|
} from "./utils/analyticRouteHits.utils.js";
|
||||||
import { createCronJob } from "./utils/croner.utils.js";
|
import { createCronJob } from "./utils/croner.utils.js";
|
||||||
import { sendEmail } from "./utils/sendEmail.utils.js";
|
import { sendEmail } from "./utils/sendEmail.utils.js";
|
||||||
|
|
||||||
@@ -68,10 +73,16 @@ const start = async () => {
|
|||||||
createCronJob("logsCleanup", "0 15 5 * * *", () => dbCleanup("logs", 120));
|
createCronJob("logsCleanup", "0 15 5 * * *", () => dbCleanup("logs", 120));
|
||||||
historicalSchedule();
|
historicalSchedule();
|
||||||
|
|
||||||
|
createCronJob("aggregateHits", "0 0 7 * * *", async () =>
|
||||||
|
runRouteHitAnalyticsCron(),
|
||||||
|
);
|
||||||
|
|
||||||
|
createCronJob("cleanHitsUp", "0 0 7 * * *", () => cleanupOldRouteHits());
|
||||||
// one shots only needed to run on server startups
|
// one shots only needed to run on server startups
|
||||||
createNotifications();
|
createNotifications();
|
||||||
startNotifications();
|
startNotifications();
|
||||||
serversChecks();
|
serversChecks();
|
||||||
|
aggregateRouteHitsForBusinessDay();
|
||||||
}, 5 * 1000);
|
}, 5 * 1000);
|
||||||
|
|
||||||
process.on("uncaughtException", async (err) => {
|
process.on("uncaughtException", async (err) => {
|
||||||
|
|||||||
17
migrations/0050_concerned_vivisector.sql
Normal file
17
migrations/0050_concerned_vivisector.sql
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
CREATE TABLE "analytics_daily" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"business_date" date NOT NULL,
|
||||||
|
"method" text NOT NULL,
|
||||||
|
"route_pattern" text NOT NULL,
|
||||||
|
"module" text NOT NULL,
|
||||||
|
"total_hits" integer NOT NULL,
|
||||||
|
"unique_users" integer NOT NULL,
|
||||||
|
"success_count" integer NOT NULL,
|
||||||
|
"error_count" integer NOT NULL,
|
||||||
|
"avg_duration_ms" integer NOT NULL,
|
||||||
|
"max_duration_ms" integer NOT NULL,
|
||||||
|
"first_hit_at" timestamp NOT NULL,
|
||||||
|
"last_hit_at" timestamp NOT NULL,
|
||||||
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
2349
migrations/meta/0050_snapshot.json
Normal file
2349
migrations/meta/0050_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -351,6 +351,13 @@
|
|||||||
"when": 1778166074209,
|
"when": 1778166074209,
|
||||||
"tag": "0049_futuristic_silk_fever",
|
"tag": "0049_futuristic_silk_fever",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 50,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1778169641819,
|
||||||
|
"tag": "0050_concerned_vivisector",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -106,6 +106,8 @@ function Update-Server {
|
|||||||
"CLIENT_SECRET" = "zsJeyjMN2yDDqfyzSsh96OtlA2714F5d"
|
"CLIENT_SECRET" = "zsJeyjMN2yDDqfyzSsh96OtlA2714F5d"
|
||||||
"CLIENT_SCOPES" = "openid profile email groups"
|
"CLIENT_SCOPES" = "openid profile email groups"
|
||||||
"DISCOVERY_URL" = "https://auth.tuffraid.net/oidc/.well-known/openid-configuration"
|
"DISCOVERY_URL" = "https://auth.tuffraid.net/oidc/.well-known/openid-configuration"
|
||||||
|
"UMAMI_HOST" = "https://stats.tuffraid.net"
|
||||||
|
"UMAMI_WEBSITE_ID" = "49bc2489-3930-4358-a13d-1cc609336572"
|
||||||
}
|
}
|
||||||
|
|
||||||
$linesToAppend = @()
|
$linesToAppend = @()
|
||||||
|
|||||||
Reference in New Issue
Block a user