mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
feat: Add projectId to various monitor response and criteria interfaces
This commit is contained in:
parent
d84654e680
commit
e301e253d0
15 changed files with 38 additions and 5 deletions
|
|
@ -32,6 +32,7 @@ export default class APIRequestCriteria {
|
|||
) {
|
||||
try {
|
||||
overTimeValue = await EvaluateOverTime.getValueOverTime({
|
||||
projectId: (input.dataToProcess as ProbeMonitorResponse).projectId,
|
||||
monitorId: input.dataToProcess.monitorId!,
|
||||
evaluateOverTimeOptions: input.criteriaFilter.evaluateOverTimeOptions,
|
||||
metricType: input.criteriaFilter.checkOn,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import Query from "../../../Types/AnalyticsDatabase/Query";
|
||||
import GreaterThanOrEqual from "Common/Types/BaseDatabase/GreaterThanOrEqual";
|
||||
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
|
||||
import OneUptimeDate from "Common/Types/Date";
|
||||
import { JSONObject } from "Common/Types/JSON";
|
||||
|
|
@ -13,10 +12,12 @@ import Metric from "../../../../Models/AnalyticsModels/Metric";
|
|||
import MonitorMetricTypeUtil from "../../../../Utils/Monitor/MonitorMetricType";
|
||||
import MetricService from "../../../Services/MetricService";
|
||||
import CaptureSpan from "../../Telemetry/CaptureSpan";
|
||||
import QueryHelper from "../../../Types/Database/QueryHelper";
|
||||
|
||||
export default class EvaluateOverTime {
|
||||
@CaptureSpan()
|
||||
public static async getValueOverTime(data: {
|
||||
projectId: ObjectID;
|
||||
monitorId: ObjectID;
|
||||
evaluateOverTimeOptions: EvaluateOverTimeOptions;
|
||||
metricType: CheckOn;
|
||||
|
|
@ -30,8 +31,11 @@ export default class EvaluateOverTime {
|
|||
|
||||
// TODO: Query over miscData
|
||||
|
||||
const now: Date = OneUptimeDate.getCurrentDate();
|
||||
|
||||
const query: Query<Metric> = {
|
||||
createdAt: new GreaterThanOrEqual(lastMinutesDate),
|
||||
projectId: data.projectId,
|
||||
time: QueryHelper.inBetween(lastMinutesDate, now),
|
||||
serviceId: data.monitorId,
|
||||
name: MonitorMetricTypeUtil.getMonitorMeticTypeByCheckOn(data.metricType),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ export default class IncomingRequestCriteria {
|
|||
) {
|
||||
try {
|
||||
overTimeValue = await EvaluateOverTime.getValueOverTime({
|
||||
projectId: (input.dataToProcess as IncomingMonitorRequest).projectId,
|
||||
monitorId: input.dataToProcess.monitorId!,
|
||||
evaluateOverTimeOptions: input.criteriaFilter.evaluateOverTimeOptions,
|
||||
metricType: input.criteriaFilter.checkOn,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export default class ServerMonitorCriteria {
|
|||
) {
|
||||
try {
|
||||
overTimeValue = await EvaluateOverTime.getValueOverTime({
|
||||
projectId: (input.dataToProcess as ProbeMonitorResponse).projectId,
|
||||
monitorId: input.dataToProcess.monitorId!,
|
||||
evaluateOverTimeOptions: input.criteriaFilter.evaluateOverTimeOptions,
|
||||
metricType: input.criteriaFilter.checkOn,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ export default class ServerMonitorCriteria {
|
|||
) {
|
||||
try {
|
||||
overTimeValue = await EvaluateOverTime.getValueOverTime({
|
||||
projectId: (input.dataToProcess as ServerMonitorResponse).projectId,
|
||||
monitorId: input.dataToProcess.monitorId!,
|
||||
evaluateOverTimeOptions: input.criteriaFilter.evaluateOverTimeOptions,
|
||||
metricType: input.criteriaFilter.checkOn,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ export default class SyntheticMonitoringCriteria {
|
|||
// check custom code monitoring criteria first
|
||||
const result: string | null =
|
||||
await CustomCodeMonitoringCriteria.isMonitorInstanceCriteriaFilterMet({
|
||||
|
||||
monitorResponse: syntheticMonitorResponse,
|
||||
criteriaFilter: input.criteriaFilter,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ export default class MonitorResourceUtil {
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
logger.debug("Monitor found");
|
||||
logger.debug("Monitor ID: " + dataToProcess.monitorId);
|
||||
|
||||
|
|
@ -110,6 +112,15 @@ export default class MonitorResourceUtil {
|
|||
throw new BadDataException("Monitor not found");
|
||||
}
|
||||
|
||||
if(!monitor.projectId){
|
||||
logger.debug(
|
||||
`${dataToProcess.monitorId.toString()} Monitor does not have a projectId`,
|
||||
);
|
||||
throw new BadDataException("Monitor does not have a projectId");
|
||||
}
|
||||
|
||||
dataToProcess.projectId = monitor.projectId;
|
||||
|
||||
if (monitor.disableActiveMonitoring) {
|
||||
logger.debug(
|
||||
`${dataToProcess.monitorId.toString()} Monitor is disabled. Please enable it to start monitoring again.`,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { JSONObject } from "../../JSON";
|
|||
import ObjectID from "../../ObjectID";
|
||||
|
||||
export default interface IncomingMonitorRequest {
|
||||
projectId: ObjectID;
|
||||
monitorId: ObjectID;
|
||||
requestHeaders?: Dictionary<string> | undefined;
|
||||
requestBody?: string | JSONObject | undefined;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import Query from "../../BaseDatabase/Query";
|
|||
import ObjectID from "../../ObjectID";
|
||||
|
||||
export default interface LogMonitorResponse {
|
||||
projectId: ObjectID;
|
||||
logCount: number;
|
||||
logQuery: Query<Log>;
|
||||
monitorId: ObjectID;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import MetricsViewConfig from "../../Metrics/MetricsViewConfig";
|
|||
import ObjectID from "../../ObjectID";
|
||||
|
||||
export default interface MetricMonitorResponse {
|
||||
projectId: ObjectID;
|
||||
startAndEndDate?: InBetween<Date>;
|
||||
metricResult: Array<AggregatedResult>;
|
||||
metricViewConfig: MetricsViewConfig;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export interface ServerProcess {
|
|||
}
|
||||
|
||||
export default interface ServerMonitorResponse {
|
||||
projectId: ObjectID;
|
||||
monitorId: ObjectID;
|
||||
hostname: string; // Hostname of the server
|
||||
basicInfrastructureMetrics?: BasicInfrastructureMetrics | undefined;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import ObjectID from "../../ObjectID";
|
|||
import Span from "../../../Models/AnalyticsModels/Span";
|
||||
|
||||
export default interface TraceMonitorResponse {
|
||||
projectId: ObjectID;
|
||||
spanCount: number;
|
||||
spanQuery: Query<Span>;
|
||||
monitorId: ObjectID;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import ObjectID from "../ObjectID";
|
|||
import Port from "../Port";
|
||||
|
||||
export default interface ProbeMonitorResponse {
|
||||
projectId: ObjectID;
|
||||
isOnline?: boolean | undefined;
|
||||
monitorDestination?: URL | IP | Hostname | undefined;
|
||||
monitorDestinationPort?: Port | undefined;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ const processIncomingRequest: RequestHandler = async (
|
|||
},
|
||||
select: {
|
||||
_id: true,
|
||||
projectId: true,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
|
|
@ -67,8 +68,13 @@ const processIncomingRequest: RequestHandler = async (
|
|||
throw new BadDataException("Monitor not found");
|
||||
}
|
||||
|
||||
if(!monitor.projectId) {
|
||||
throw new BadDataException("Project not found");
|
||||
}
|
||||
|
||||
const incomingRequest: IncomingMonitorRequest = {
|
||||
monitorId: new ObjectID(monitor._id),
|
||||
projectId: monitor.projectId,
|
||||
monitorId: new ObjectID(monitor._id.toString()),
|
||||
requestHeaders: requestHeaders,
|
||||
requestBody: requestBody,
|
||||
incomingRequestReceivedAt: OneUptimeDate.getCurrentDate(),
|
||||
|
|
|
|||
5
IncomingRequestIngest/package-lock.json
generated
5
IncomingRequestIngest/package-lock.json
generated
|
|
@ -27,7 +27,7 @@
|
|||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@bull-board/express": "^5.21.4",
|
||||
"@clickhouse/client": "^1.8.1",
|
||||
"@clickhouse/client": "^1.10.1",
|
||||
"@elastic/elasticsearch": "^8.12.1",
|
||||
"@monaco-editor/react": "^4.4.6",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
"nodemailer": "^6.9.10",
|
||||
"otpauth": "^9.3.1",
|
||||
"pg": "^8.7.3",
|
||||
"playwright": "^1.48.2",
|
||||
"playwright": "^1.50.0",
|
||||
"posthog-js": "^1.139.6",
|
||||
"prop-types": "^15.8.1",
|
||||
"qrcode": "^1.5.3",
|
||||
|
|
@ -105,6 +105,7 @@
|
|||
"redis-semaphore": "^5.5.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"remark-gfm": "^3.0.1",
|
||||
"slackify-markdown": "^4.4.0",
|
||||
"slugify": "^1.6.5",
|
||||
"socket.io": "^4.7.4",
|
||||
"socket.io-client": "^4.7.5",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue