mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Remove MonitorMetricsByMinute model and related service and job files
This commit is contained in:
parent
eb20a3c9a2
commit
108dfaccf8
@ -1,177 +0,0 @@
|
|||||||
import AnalyticsBaseModel from "./AnalyticsBaseModel/AnalyticsBaseModel";
|
|
||||||
import Route from "../../Types/API/Route";
|
|
||||||
import AnalyticsTableEngine from "../../Types/AnalyticsDatabase/AnalyticsTableEngine";
|
|
||||||
import AnalyticsTableColumn from "../../Types/AnalyticsDatabase/TableColumn";
|
|
||||||
import TableColumnType from "../../Types/AnalyticsDatabase/TableColumnType";
|
|
||||||
import BrowserType from "../../Types/BrowserType";
|
|
||||||
import { JSONObject } from "../../Types/JSON";
|
|
||||||
import { CheckOn } from "../../Types/Monitor/CriteriaFilter";
|
|
||||||
import ObjectID from "../../Types/ObjectID";
|
|
||||||
import Permission from "../../Types/Permission";
|
|
||||||
import ScreenSizeType from "../../Types/ScreenSizeType";
|
|
||||||
|
|
||||||
export interface MonitorMetricsMiscData {
|
|
||||||
diskPath?: string;
|
|
||||||
probeId?: string;
|
|
||||||
browserType?: BrowserType;
|
|
||||||
screenSizeType?: ScreenSizeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MonitorMetricsByMinute extends AnalyticsBaseModel {
|
|
||||||
public constructor() {
|
|
||||||
super({
|
|
||||||
tableName: "MonitorMetrics",
|
|
||||||
tableEngine: AnalyticsTableEngine.MergeTree,
|
|
||||||
singularName: "Monitor Metric",
|
|
||||||
pluralName: "Monitor Metrics",
|
|
||||||
accessControl: {
|
|
||||||
read: [
|
|
||||||
Permission.ProjectOwner,
|
|
||||||
Permission.ProjectAdmin,
|
|
||||||
Permission.ProjectMember,
|
|
||||||
Permission.ReadProjectMonitor,
|
|
||||||
],
|
|
||||||
create: [],
|
|
||||||
update: [],
|
|
||||||
delete: [],
|
|
||||||
},
|
|
||||||
crudApiPath: new Route("/monitor-metrics"),
|
|
||||||
tableColumns: [
|
|
||||||
new AnalyticsTableColumn({
|
|
||||||
key: "projectId",
|
|
||||||
title: "Project ID",
|
|
||||||
description: "ID of project",
|
|
||||||
required: true,
|
|
||||||
type: TableColumnType.ObjectID,
|
|
||||||
isTenantId: true,
|
|
||||||
accessControl: {
|
|
||||||
read: [
|
|
||||||
Permission.ProjectOwner,
|
|
||||||
Permission.ProjectAdmin,
|
|
||||||
Permission.ProjectMember,
|
|
||||||
Permission.ReadProjectMonitor,
|
|
||||||
],
|
|
||||||
create: [],
|
|
||||||
update: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
new AnalyticsTableColumn({
|
|
||||||
key: "monitorId",
|
|
||||||
title: "Monitor ID",
|
|
||||||
description: "ID of the Monitor which this metric belongs to",
|
|
||||||
required: true,
|
|
||||||
type: TableColumnType.ObjectID,
|
|
||||||
accessControl: {
|
|
||||||
read: [
|
|
||||||
Permission.ProjectOwner,
|
|
||||||
Permission.ProjectAdmin,
|
|
||||||
Permission.ProjectMember,
|
|
||||||
Permission.ReadProjectMonitor,
|
|
||||||
],
|
|
||||||
create: [],
|
|
||||||
update: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
new AnalyticsTableColumn({
|
|
||||||
key: "metricType",
|
|
||||||
title: "Metric Type",
|
|
||||||
description: "Type of metric",
|
|
||||||
required: true,
|
|
||||||
type: TableColumnType.Text,
|
|
||||||
accessControl: {
|
|
||||||
read: [
|
|
||||||
Permission.ProjectOwner,
|
|
||||||
Permission.ProjectAdmin,
|
|
||||||
Permission.ProjectMember,
|
|
||||||
Permission.ReadProjectMonitor,
|
|
||||||
],
|
|
||||||
create: [],
|
|
||||||
update: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
new AnalyticsTableColumn({
|
|
||||||
key: "metricValue",
|
|
||||||
title: "Metric Value",
|
|
||||||
description: "Value of the metric",
|
|
||||||
required: true,
|
|
||||||
type: TableColumnType.Number,
|
|
||||||
accessControl: {
|
|
||||||
read: [
|
|
||||||
Permission.ProjectOwner,
|
|
||||||
Permission.ProjectAdmin,
|
|
||||||
Permission.ProjectMember,
|
|
||||||
Permission.ReadProjectMonitor,
|
|
||||||
],
|
|
||||||
create: [],
|
|
||||||
update: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
new AnalyticsTableColumn({
|
|
||||||
key: "miscData",
|
|
||||||
title: "Misc Data",
|
|
||||||
description: "Misc data for the metric (if any)",
|
|
||||||
required: false,
|
|
||||||
type: TableColumnType.JSON,
|
|
||||||
accessControl: {
|
|
||||||
read: [
|
|
||||||
Permission.ProjectOwner,
|
|
||||||
Permission.ProjectAdmin,
|
|
||||||
Permission.ProjectMember,
|
|
||||||
Permission.ReadProjectMonitor,
|
|
||||||
],
|
|
||||||
create: [],
|
|
||||||
update: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
sortKeys: ["projectId", "monitorId", "createdAt"],
|
|
||||||
primaryKeys: ["projectId", "monitorId"],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public get projectId(): ObjectID | undefined {
|
|
||||||
return this.getColumnValue("projectId") as ObjectID | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set projectId(v: ObjectID | undefined) {
|
|
||||||
this.setColumnValue("projectId", v);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get monitorId(): ObjectID | undefined {
|
|
||||||
return this.getColumnValue("monitorId") as ObjectID | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set monitorId(v: ObjectID | undefined) {
|
|
||||||
this.setColumnValue("monitorId", v);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get metricType(): CheckOn | undefined {
|
|
||||||
return this.getColumnValue("metricType") as CheckOn | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set metricType(v: CheckOn | undefined) {
|
|
||||||
this.setColumnValue("metricType", v);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get metricValue(): number | undefined {
|
|
||||||
return this.getColumnValue("metricValue") as number | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set metricValue(v: number | undefined) {
|
|
||||||
this.setColumnValue("metricValue", v);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get miscData(): MonitorMetricsMiscData | undefined {
|
|
||||||
return this.getColumnValue("miscData") as
|
|
||||||
| MonitorMetricsMiscData
|
|
||||||
| undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set miscData(v: MonitorMetricsMiscData | undefined) {
|
|
||||||
this.setColumnValue("miscData", v as JSONObject);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
import ClickhouseDatabase from "../Infrastructure/ClickhouseDatabase";
|
|
||||||
import AnalyticsDatabaseService from "./AnalyticsDatabaseService";
|
|
||||||
import MonitorMetricsByMinute from "Common/Models/AnalyticsModels/MonitorMetricsByMinute";
|
|
||||||
|
|
||||||
export class MonitorMetricsByMinuteService extends AnalyticsDatabaseService<MonitorMetricsByMinute> {
|
|
||||||
public constructor(clickhouseDatabase?: ClickhouseDatabase | undefined) {
|
|
||||||
super({
|
|
||||||
modelType: MonitorMetricsByMinute,
|
|
||||||
database: clickhouseDatabase,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default new MonitorMetricsByMinuteService();
|
|
@ -1,25 +0,0 @@
|
|||||||
import RunCron from "../../Utils/Cron";
|
|
||||||
import LessThan from "Common/Types/BaseDatabase/LessThan";
|
|
||||||
import OneUptimeDate from "Common/Types/Date";
|
|
||||||
import { EVERY_MINUTE } from "Common/Utils/CronTime";
|
|
||||||
import MonitorMetricsByMinuteService from "Common/Server/Services/MonitorMetricsByMinuteService";
|
|
||||||
|
|
||||||
// Schedule a cron job to run every minute
|
|
||||||
RunCron(
|
|
||||||
"MonitorMetrics:HardDeleteMonitorMetricsByMinute",
|
|
||||||
{ schedule: EVERY_MINUTE, runOnStartup: false },
|
|
||||||
async () => {
|
|
||||||
// Calculate the timestamp for one hour ago
|
|
||||||
const oneHourAgo: Date = OneUptimeDate.getSomeMinutesAgo(60);
|
|
||||||
|
|
||||||
// Delete all monitor metrics older than one hour
|
|
||||||
await MonitorMetricsByMinuteService.deleteBy({
|
|
||||||
query: {
|
|
||||||
createdAt: new LessThan(oneHourAgo),
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
isRoot: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
Loading…
Reference in New Issue
Block a user