Skip to content

Commit

Permalink
Merge pull request #1293 from OneUptime/nivo-chart
Browse files Browse the repository at this point in the history
Add @nivo/bar, @nivo/core, and @nivo/line dependencies***
  • Loading branch information
simlarsen authored Mar 31, 2024
2 parents bc72200 + f61e44f commit ed3e0e0
Show file tree
Hide file tree
Showing 15 changed files with 1,207 additions and 6 deletions.
13 changes: 13 additions & 0 deletions App/FeatureSet/BaseAPI/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ import LogService, {
LogService as LogServiceType,
} from 'CommonServer/Services/LogService';

import MonitorMetricsByMinute from 'Model/AnalyticsModels/MonitorMetricsByMinute';
import MonitorMetricsByMinuteService, {
MonitorMetricsByMinuteService as MonitorMetricsByMinuteServiceType,
} from 'CommonServer/Services/MonitorMetricsByMinuteService';

import Span from 'Model/AnalyticsModels/Span';
import SpanService, {
SpanService as SpanServiceType,
Expand Down Expand Up @@ -458,6 +463,14 @@ app.use(
new BaseAnalyticsAPI<Log, LogServiceType>(Log, LogService).getRouter()
);

app.use(
`/${APP_NAME.toLocaleLowerCase()}`,
new BaseAnalyticsAPI<
MonitorMetricsByMinute,
MonitorMetricsByMinuteServiceType
>(MonitorMetricsByMinute, MonitorMetricsByMinuteService).getRouter()
);

app.use(
`/${APP_NAME.toLocaleLowerCase()}`,
new BaseAnalyticsAPI<Span, SpanServiceType>(Span, SpanService).getRouter()
Expand Down
1 change: 1 addition & 0 deletions Common/Types/BrandColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Grey: Color = Color.fromString('#575757');
export const LightGrey: Color = Color.fromString('#908B8B');
export const Moroon: Color = Color.fromString('#b70400');
export const Blue: Color = Color.fromString('#3686be');
export const Indigo500: Color = Color.fromString('#6366f1');

export const EventColorList: Color[] = [
Color.fromString('#d50000'),
Expand Down
5 changes: 5 additions & 0 deletions Common/Types/Date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default class OneUptimeDate {
return date.getTime() * 1000000;
}

public static getLocalHourAndMinuteFromDate(date: Date | string): string {
date = this.fromString(date);
return moment(date).format('HH:mm');
}

public static getMillisecondsBetweenTwoUnixNanoDates(
startDate: number,
endDate: number
Expand Down
38 changes: 38 additions & 0 deletions Common/Types/JSONFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,44 @@ export default class JSONFunctions {
return Object.keys(obj).length === 0;
}

public static isEqualObject(
obj1: JSONObject | undefined,
obj2: JSONObject | undefined
): boolean {
// check if all the keys are the same

if (!obj1 && !obj2) {
return true;
}

if (!obj1 || !obj2) {
return false;
}

const keys1: Array<string> = Object.keys(obj1);
const keys2: Array<string> = Object.keys(obj2);

if (keys1.length !== keys2.length) {
return false;
}

for (const key of keys1) {
if (!keys2.includes(key)) {
return false;
}
}

// check if all the values are the same

for (const key of keys1) {
if (obj1[key] !== obj2[key]) {
return false;
}
}

return true;
}

public static toCompressedString(val: JSONValue): string {
return JSON.stringify(val, null, 2);
}
Expand Down
26 changes: 26 additions & 0 deletions Common/Types/Monitor/CriteriaFilter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import MonitorType from './MonitorType';

export enum CheckOn {
ResponseTime = 'Response Time (in ms)',
ResponseStatusCode = 'Response Status Code',
Expand Down Expand Up @@ -89,4 +91,28 @@ export class CriteriaFilterUtil {
checkOn === CheckOn.MemoryUsagePercent
);
}

public static getTimeFiltersByMonitorType(
monitorType: MonitorType
): Array<CheckOn> {
if (
monitorType === MonitorType.API ||
monitorType === MonitorType.Website
) {
return [CheckOn.ResponseStatusCode, CheckOn.ResponseTime];
} else if (
monitorType === MonitorType.Ping ||
monitorType === MonitorType.IP ||
monitorType === MonitorType.Port
) {
return [CheckOn.ResponseTime];
} else if (monitorType === MonitorType.Server) {
return [
CheckOn.DiskUsagePercent,
CheckOn.CPUUsagePercent,
CheckOn.MemoryUsagePercent,
];
}
return [];
}
}
18 changes: 18 additions & 0 deletions CommonServer/Utils/Probe/ProbeMonitorResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,24 @@ export default class ProbeMonitorResponseService {
},
});
}

if ((data.dataToProcess as ProbeMonitorResponse).responseCode) {
const monitorMetricsByMinute: MonitorMetricsByMinute =
new MonitorMetricsByMinute();
monitorMetricsByMinute.monitorId = data.monitorId;
monitorMetricsByMinute.projectId = data.projectId;
monitorMetricsByMinute.metricType = CheckOn.ResponseStatusCode;
monitorMetricsByMinute.metricValue = (
data.dataToProcess as ProbeMonitorResponse
).responseCode;

await MonitorMetricsByMinuteService.create({
data: monitorMetricsByMinute,
props: {
isRoot: true,
},
});
}
}

private static async checkOpenIncidentsAndCloseIfResolved(input: {
Expand Down
Loading

0 comments on commit ed3e0e0

Please sign in to comment.