Skip to content

Commit

Permalink
[CON-395] Add start time to network monitoring slack alert (#3887)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaylor89 committed Sep 19, 2022
1 parent 05d7766 commit 95cc726
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -21,6 +21,7 @@ import {
getUsersWithNullPrimaryClock,
getUsersWithEntireReplicaSetInSpidSetCount,
getUserCount,
getRunStartTime,
} from "./queries";

export const generateMetrics = async (run_id: number) => {
Expand All @@ -30,6 +31,8 @@ export const generateMetrics = async (run_id: number) => {

const endTimer = generatingMetricsDurationGauge.startTimer();

const runStartTime = await getRunStartTime(run_id);

const userCount = await getUserCount(run_id);

const allUserCount = await getAllUserCount(run_id);
Expand Down Expand Up @@ -69,6 +72,7 @@ export const generateMetrics = async (run_id: number) => {

if (userCount > 0) {
await publishSlackReport({
runStartTime: runStartTime.toString(),
fullySyncedUsersCount:
((fullySyncedUsersCount / userCount) * 100).toFixed(2) + "%",
partiallySyncedUsersCount:
Expand Down
Expand Up @@ -30,6 +30,24 @@ export const getUserCount = async (run_id: number): Promise<number> => {
* Core metrics
*/

export const getRunStartTime = async (run_id: number): Promise<Date> => {
const runStartTimeResp: unknown[] = await sequelizeConn.query(`
SELECT created_at
FROM
network_monitoring_index_blocks
WHERE
run_id = :run_id
`, {
type: QueryTypes.SELECT,
replacements: { run_id }
})

const runStartTimeStr = (runStartTimeResp[0] as { created_at: string }).created_at as string
const runStartTime = new Date(runStartTimeStr)

return runStartTime
}

export const getCidsReplicatedAtLeastOnce = async (run_id: number): Promise<{ content_node_spid: string, cid_count: number }[]> => {

const cidsListResp = await sequelizeConn.query(`
Expand Down

0 comments on commit 95cc726

Please sign in to comment.