Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Complete Uptime

Yehor Dremliuha4b3624dd51ac
diff --git a/apps/production/src/analytics/analytics.controller.ts b/apps/production/src/analytics/analytics.controller.ts
index 40284f6ea..a8faa2e29 100644
--- a/apps/production/src/analytics/analytics.controller.ts
+++ b/apps/production/src/analytics/analytics.controller.ts
@@ -9,7 +9,12 @@ import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import * as dayjsTimezone from 'dayjs/plugin/timezone'
import { hash } from 'blake3'
-import { ApiOperation, ApiOkResponse } from '@nestjs/swagger'
+import {
+ ApiOperation,
+ ApiOkResponse,
+ ApiBearerAuth,
+ ApiTags,
+} from '@nestjs/swagger'
import {
Controller,
Body,
@@ -29,7 +34,6 @@ import {
ConflictException,
NotFoundException,
} from '@nestjs/common'
-import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'
import * as UAParser from 'ua-parser-js'
import { isbot } from 'isbot'
@@ -94,6 +98,7 @@ import {
performanceTransformer,
trafficTransformer,
} from './utils/transformers'
+import { GetUptimeBirdseyeDto } from './dto/get-uptime-birdseye.dto'
dayjs.extend(utc)
dayjs.extend(dayjsTimezone)
@@ -163,6 +168,38 @@ const getPIDsArray = (pids, pid) => {
return pids
}
+const getMonitorIdsArray = (monitorIds, monitorId) => {
+ const idsEmpty = _isEmpty(monitorIds)
+ const idEmpty = _isEmpty(monitorId)
+ if (idsEmpty && idEmpty)
+ throw new BadRequestException(
+ 'An array of Monitor IDs (monitorIds) or a Monitor ID (monitorId) has to be provided',
+ )
+ else if (!idsEmpty && !idEmpty)
+ throw new BadRequestException(
+ 'Please provide either an array of Monitor IDs (monitorIds) or a Monitor ID (monitorId), but not both',
+ )
+ else if (!idEmpty) {
+ monitorIds = JSON.stringify([monitorId])
+ }
+
+ try {
+ monitorIds = JSON.parse(monitorIds)
+ } catch (e) {
+ throw new UnprocessableEntityException(
+ "Cannot process the provided array of Monitor ID's",
+ )
+ }
+
+ if (!_isArray(monitorIds)) {
+ throw new UnprocessableEntityException(
+ "An array of Monitor ID's has to be provided as a 'monitorIds' param",
+ )
+ }
+
+ return monitorIds
+}
+
const getEIDsArray = (eids, eid) => {
const eidsEmpty = _isEmpty(eids)
const eidEmpty = _isEmpty(eid)
@@ -1573,6 +1610,55 @@ export class AnalyticsController {
}
}
+ @Get('monitor-data/birdseye')
+ @Auth([], true, true)
+ async getUptimeBirdseye(
+ @Query() parameters: GetUptimeBirdseyeDto,
+ @CurrentUserId() uid: string,
+ @Headers() headers: { 'x-password'?: string },
+ ): Promise<any> {
+ const {
+ pid,
+ monitorGroupId,
+ monitorId,
+ monitorIds,
+ period,
+ from,
+ to,
+ timezone = DEFAULT_TIMEZONE,
+ } = parameters
+
+ this.analyticsService.validatePID(pid)
+
+ await this.analyticsService.checkProjectAccess(
+ pid,
+ uid,
+ headers['x-password'],
+ )
+
+ await this.analyticsService.checkBillingAccess(pid)
+
+ const idsArray = getMonitorIdsArray(monitorIds, monitorId)
+
+ const validationPromises = _map(idsArray, async currentId => {
+ await this.analyticsService.checkUptimeAccess(
+ pid,
+ monitorGroupId,
+ currentId,
+ )
+ })
+
+ await Promise.all(validationPromises)
+
+ return this.analyticsService.getUptimeSummary(
+ idsArray,
+ period,
+ from,
+ to,
+ timezone,
+ )
+ }
+
@ApiOperation({ summary: 'Get monitor data' })
@ApiBearerAuth()
@ApiOkResponse({ description: 'Monitor data retrieved successfully' })
@@ -1585,13 +1671,13 @@ export class AnalyticsController {
): Promise<any & { chart: any }> {
const {
pid,
- // monitorGroupId,
+ monitorGroupId,
monitorId,
period,
timeBucket,
from,
to,
- timezone,
+ timezone = DEFAULT_TIMEZONE,
} = parameters
// TODO: CHECK THAT MONITOR GROUP BELONGS TO THE PROVIDED PID
@@ -1609,6 +1695,12 @@ export class AnalyticsController {
await this.analyticsService.checkBillingAccess(pid)
+ await this.analyticsService.checkUptimeAccess(
+ pid,
+ monitorGroupId,
+ monitorId,
+ )
+
let newTimebucket = timeBucket
let allowedTumebucketForPeriodAll
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index 1ef2d1b8c..5cf6385ff 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -37,6 +37,7 @@ import {
HttpStatus,
UnprocessableEntityException,
PreconditionFailedException,
+ ForbiddenException,
} from '@nestjs/common'
import { DEFAULT_TIMEZONE } from '../user/entities/user.entity'
@@ -97,6 +98,7 @@ import {
PropertiesCHResponse,
IPageProperty,
ICustomEvent,
+ BirdseyeCHUptimeResponse,
} from './interfaces'
import { ErrorDTO } from './dto/error.dto'
import { GetPagePropertyMetaDTO } from './dto/get-page-property-meta.dto'
@@ -392,6 +394,25 @@ export class AnalyticsService {
}
}
+ async checkUptimeAccess(
+ pid: string,
+ monitorGroupId: string,
+ monitorId: number,
+ ) {
+ const monitor = await this.projectService.findMonitorById(
+ monitorId as unknown as string,
+ monitorGroupId,
+ pid,
+ {
+ relations: ['group'],
+ },
+ )
+
+ if (!monitor) {
+ throw new ForbiddenException('You are not allowed to view this project')
+ }
+ }
+
checkOrigin(project: Project, origin: string): void {
// For some reasons the project.origins sometimes may look like [''], let's filter it out
// TODO: Properly validate the origins on project update
@@ -1386,6 +1407,173 @@ export class AnalyticsService {
return result
}
+ async getUptimeSummary(
+ monitorIds: number[],
+ period?: string,
+ from?: string,
+ to?: string,
+ timezone?: string,
+ ): Promise<IOverallCaptcha> {
+ // eslint-disable-next-line
+ let _from: string
+ // eslint-disable-next-line
+ let _to: string
+
+ if (_isEmpty(period) || ['today', 'yesterday', 'custom'].includes(period)) {
+ const safeTimezone = this.getSafeTimezone(timezone)
+
+ const { groupFrom, groupTo } = this.getGroupFromTo(
+ from,
+ to,
+ ['today', 'yesterday'].includes(period) ? TimeBucketType.HOUR : null,
+ period,
+ safeTimezone,
+ )
+
+ _from = groupFrom
+ _to = groupTo
+ } else {
+ this.validatePeriod(period)
+ }
+
+ const result = {}
+
+ const promises = monitorIds.map(async monitorId => {
+ try {
+ if (period === 'all') {
+ const queryAll = `
+ SELECT
+ coalesce(divide(avg(responseTime), 1000), 0) as avg,
+ coalesce(divide(max(responseTime), 1000), 0) as max,
+ coalesce(divide(min(responseTime), 1000), 0) as min
+ FROM
+ monitor_responses
+ WHERE
+ monitorId={monitorId:UInt64}
+ `
+
+ const { data } = await clickhouse
+ .query({
+ query: queryAll,
+ query_params: { monitorId },
+ })
+ .then(resultSet => resultSet.json<BirdseyeCHUptimeResponse>())
+
+ result[monitorId] = {
+ current: {
+ avg: data[0].avg,
+ min: data[0].min,
+ max: data[0].max,
+ },
+ previous: {
+ avg: 0,
+ min: 0,
+ max: 0,
+ },
+ avgChange: data[0].avg,
+ minChange: data[0].min,
+ maxChange: data[0].max,
+ }
+ return
+ }
+
+ let now: string
+ let periodFormatted: string
+ let periodSubtracted: string
+
+ if (_from && _to) {
+ // diff may be 0 (when selecting data for 1 day), so let's make it 1 to grab some data for the prev day as well
+ const diff = dayjs(_to).diff(dayjs(_from), 'days') || 1
+
+ now = _to
+ periodFormatted = _from
+ periodSubtracted = dayjs(_from)
+ .subtract(diff, 'days')
+ .format('YYYY-MM-DD HH:mm:ss')
+ } else {
+ const amountToSubtract = parseInt(period, 10)
+ const unit = _replace(period, /[0-9]/g, '')
+
+ now = dayjs.utc().format('YYYY-MM-DD HH:mm:ss')
+ const periodRaw = dayjs.utc().subtract(amountToSubtract, unit)
+ periodFormatted = periodRaw.format('YYYY-MM-DD HH:mm:ss')
+ periodSubtracted = periodRaw
+ .subtract(amountToSubtract, unit)
+ .format('YYYY-MM-DD HH:mm:ss')
+ }
+
+ const queryCurrent = `
+ SELECT
+ 1 AS sortOrder,
+ coalesce(divide(avg(responseTime), 1000), 0) as avg,
+ coalesce(divide(max(responseTime), 1000), 0) as max,
+ coalesce(divide(min(responseTime), 1000), 0) as min
+ FROM
+ monitor_responses
+ WHERE
+ monitorId={monitorId:UInt64}
+ AND created BETWEEN {periodFormatted:String} AND {now:String}
+ `
+
+ const queryPrevious = `
+ SELECT
+ 2 AS sortOrder,
+ coalesce(divide(avg(responseTime), 1000), 0) as avg,
+ coalesce(divide(max(responseTime), 1000), 0) as max,
+ coalesce(divide(min(responseTime), 1000), 0) as min
+ FROM
+ monitor_responses
+ WHERE
+ monitorId={monitorId:UInt64}
+ AND created BETWEEN {periodSubtracted:String} AND {periodFormatted:String}
+ `
+
+ const query = `${queryCurrent} UNION ALL ${queryPrevious}`
+
+ let { data } = await clickhouse
+ .query({
+ query,
+ query_params: {
+ monitorId,
+ periodFormatted,
+ periodSubtracted,
+ now,
+ },
+ })
+ .then(resultSet => resultSet.json<BirdseyeCHUptimeResponse>())
+
+ data = _sortBy(data, 'sortOrder')
+
+ const currentPeriod = data[0]
+ const previousPeriod = data[1]
+
+ result[monitorId] = {
+ current: {
+ avg: currentPeriod.avg,
+ min: currentPeriod.min,
+ max: currentPeriod.max,
+ },
+ previous: {
+ avg: previousPeriod.avg || 0,
+ min: previousPeriod.min,
+ max: previousPeriod.max,
+ },
+ avgChange: currentPeriod.avg - previousPeriod.avg,
+ minChange: currentPeriod.min - previousPeriod.min,
+ maxChange: currentPeriod.max - previousPeriod.max,
+ }
+ } catch {
+ throw new InternalServerErrorException(
+ "Can't process the provided PID. Please, try again later.",
+ )
+ }
+ })
+
+ await Promise.all(promises)
+
+ return result
+ }
+
convertSummaryToObsoleteFormat(summary: IOverall): any {
const result = {}
diff --git a/apps/production/src/analytics/dto/get-monitor-data.dto.ts b/apps/production/src/analytics/dto/get-monitor-data.dto.ts
index 8190006eb..d84ee0c69 100644
--- a/apps/production/src/analytics/dto/get-monitor-data.dto.ts
+++ b/apps/production/src/analytics/dto/get-monitor-data.dto.ts
@@ -1,19 +1,7 @@
import { ApiProperty } from '@nestjs/swagger'
import { IsNotEmpty } from 'class-validator'
import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'
-
-export enum TimeBucketType {
- MINUTE = 'minute',
- HOUR = 'hour',
- DAY = 'day',
- MONTH = 'month',
- YEAR = 'year',
-}
-
-export enum ChartRenderMode {
- PERIODICAL = 'periodical',
- CUMULATIVE = 'cumulative',
-}
+import { TimeBucketType } from './getData.dto'
export class GetMonitorDataDto {
@ApiProperty()
diff --git a/apps/production/src/analytics/dto/get-uptime-birdseye.dto.ts b/apps/production/src/analytics/dto/get-uptime-birdseye.dto.ts
new file mode 100644
index 000000000..e76ae3fb3
--- /dev/null
+++ b/apps/production/src/analytics/dto/get-uptime-birdseye.dto.ts
@@ -0,0 +1,37 @@
+import { ApiProperty } from '@nestjs/swagger'
+import { IsArray, IsNotEmpty, IsOptional } from 'class-validator'
+import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'
+
+export class GetUptimeBirdseyeDto {
+ @ApiProperty()
+ @IsNotEmpty()
+ pid: string
+
+ @ApiProperty({ required: false })
+ @IsOptional()
+ monitorId?: number
+
+ @ApiProperty({ required: false })
+ @IsOptional()
+ @IsArray()
+ monitorIds?: number[]
+
+ @ApiProperty()
+ @IsNotEmpty()
+ monitorGroupId: string
+
+ @ApiProperty()
+ period: string
+
+ @ApiProperty({ required: false })
+ from: string
+
+ @ApiProperty({ required: false })
+ to: string
+
+ @ApiProperty({
+ description: 'Timezone to display data in',
+ default: DEFAULT_TIMEZONE,
+ })
+ timezone: string
+}
diff --git a/apps/production/src/analytics/interfaces/index.ts b/apps/production/src/analytics/interfaces/index.ts
index 813d0722a..896b72292 100644
--- a/apps/production/src/analytics/interfaces/index.ts
+++ b/apps/production/src/analytics/interfaces/index.ts
@@ -22,6 +22,12 @@ export interface BirdseyeCHResponse {
sdur: number
}
+export interface BirdseyeCHUptimeResponse {
+ avg: number
+ min: number
+ max: number
+}
+
export interface PerformanceCHResponse {
year: number
month: number
diff --git a/apps/production/src/app.module.ts b/apps/production/src/app.module.ts
index fb940a65a..1de585559 100644
--- a/apps/production/src/app.module.ts
+++ b/apps/production/src/app.module.ts
@@ -1,3 +1,4 @@
+import * as _toNumber from 'lodash/toNumber'
import { Module } from '@nestjs/common'
import { TypeOrmModule } from '@nestjs/typeorm'
import { ConfigModule } from '@nestjs/config'
@@ -57,13 +58,15 @@ const modules = [
username: process.env.MYSQL_USER,
password: process.env.MYSQL_ROOT_PASSWORD,
database: process.env.MYSQL_DATABASE,
- synchronize: true, // process.env.NODE_ENV !== 'production',
+ synchronize: false, // process.env.NODE_ENV !== 'production',
entities: [`${__dirname}/**/*.entity{.ts,.js}`],
}),
BullModule.forRoot({
redis: {
- host: 'localhost',
- port: 6379,
+ host: process.env.REDIS_HOST,
+ port: _toNumber(process.env.REDIS_PORT),
+ username: process.env.REDIS_USER,
+ password: process.env.REDIS_PASSWORD,
},
}),
I18nModule.forRootAsync(getI18nConfig()),
diff --git a/apps/production/src/common/templates/en/uptime-monitoring-failure.html b/apps/production/src/common/templates/en/uptime-monitoring-failure.html
index 58a03252c..d5882fcb1 100644
--- a/apps/production/src/common/templates/en/uptime-monitoring-failure.html
+++ b/apps/production/src/common/templates/en/uptime-monitoring-failure.html
@@ -1,3 +1,3 @@
-Uptime Monitoring has failed
+Hello,
-<!-- TODO status code, result make a template -->
\ No newline at end of file
+We have just detected that the monitor {{monitorName}} (monitor group - {{groupName}}, project - {{projectName}}) is down.
diff --git a/apps/production/src/mailer/mailer.service.ts b/apps/production/src/mailer/mailer.service.ts
index b0a3ee1c8..5f941893d 100644
--- a/apps/production/src/mailer/mailer.service.ts
+++ b/apps/production/src/mailer/mailer.service.ts
@@ -121,8 +121,7 @@ const metaInfoJson = {
},
[LetterTemplate.UptimeMonitoringFailure]: {
subject: {
- en: () =>
- '[ACTION REQUIRED] Your Swetrix uptime has resulted in an error',
+ en: (p: Params) => `Monitor "${p.monitorName}" is down`,
},
},
}
diff --git a/apps/production/src/project/consumers/monitor.consumer.ts b/apps/production/src/project/consumers/monitor.consumer.ts
index 73375bc50..e29632807 100644
--- a/apps/production/src/project/consumers/monitor.consumer.ts
+++ b/apps/production/src/project/consumers/monitor.consumer.ts
@@ -23,28 +23,31 @@ export class MonitorConsumer {
async httpRequestProcess(
job: Job<CreateMonitorHttpRequestDTO & { monitorId: number }>,
): Promise<any> {
- this.logger.debug(`Consumer works ${JSON.stringify(job.data)}`)
const res: {
responseTime: number
statusCode: number
timestamp: number
region: string
} = await firstValueFrom(this.monitorService.send('http-request', job.data))
- this.logger.debug(`Consumer works ${JSON.stringify(res)}`)
const monitor = await this.projectService.getMonitor(job.data.monitorId)
if (!monitor.acceptedStatusCodes.includes(res.statusCode)) {
- // await this.mailerService.sed(monitor.group.project.admin.email, 'fuck')
- await this.mailerService.sendEmail(
- monitor.group.project.admin.email,
- LetterTemplate.UptimeMonitoringFailure,
- )
+ try {
+ await this.mailerService.sendEmail(
+ monitor.group.project.admin.email,
+ LetterTemplate.UptimeMonitoringFailure,
+ {
+ projectName: monitor.group.project.name,
+ monitorName: monitor.name,
+ groupName: monitor.group.name,
+ },
+ )
+ } catch (reason) {
+ console.error('Monitor failure: sendEmail action failed')
+ console.error(reason)
+ }
}
- // this.logger.debug(`Monitor ${JSON.stringify(monitor)}`)
-
- // this.logger.debug(`1`)
- //
try {
await clickhouse.insert({
diff --git a/apps/production/src/project/project.controller.ts b/apps/production/src/project/project.controller.ts
index de1abce41..11db97c2c 100644
--- a/apps/production/src/project/project.controller.ts
+++ b/apps/production/src/project/project.controller.ts
@@ -2157,7 +2157,6 @@ export class ProjectController {
)
}
- // TODO monitor here
@ApiOperation({ summary: 'Create monitor group' })
@ApiBearerAuth()
@ApiOkResponse({ type: MonitorGroupEntity })
@@ -2168,8 +2167,6 @@ export class ProjectController {
@Body() body: CreateMonitorGroupDto,
@CurrentUserId() userId: string,
): Promise<MonitorGroupEntity> {
- this.logger.debug(`Creating monitor group: ${body.name}`)
-
const project = await this.projectService.findProject(projectId, [
'admin',
'share',
@@ -2343,12 +2340,7 @@ export class ProjectController {
@Param() { monitorGroupId }: MonitorGroupIdDto,
@Body() body: CreateMonitorHttpRequestDTO,
@CurrentUserId() userId: string,
- ): Promise<void> {
- // CREATE A MONITOR JOB HERE AS A SEPARATE PARALLEL PROCESS\
- this.logger.debug(`Request is send: ${'type'}`)
- this.logger.debug(`projectId: ${projectId}`)
- this.logger.debug(`monitorGroupId: ${monitorGroupId}`)
-
+ ): Promise<MonitorEntity> {
const project = await this.projectService.findProject(projectId, [
'admin',
'share',
@@ -2370,13 +2362,12 @@ export class ProjectController {
monitorGroupId,
projectId,
)
- this.logger.debug(`monitorGroup: ${JSON.stringify(monitorGroup)}`)
if (!monitorGroup) {
throw new NotFoundException('Monitor group not found.')
}
- const monitor = await this.projectService.createMonitor(
+ const monitor = await this.projectService.createMonitorInGroup(
body,
monitorGroup.id,
)
@@ -2386,6 +2377,8 @@ export class ProjectController {
...monitor,
timeout: monitor.timeout * 1000,
})
+
+ return monitor
}
@ApiOperation({ summary: 'Get monitor for the project' })
@@ -2531,7 +2524,5 @@ export class ProjectController {
this.projectService.deleteMonitor(monitorId)
this.projectService.deleteHttpRequest(monitorId)
-
- this.logger.debug(`Monitor with ID ${monitorId} deleted successfully.`)
}
}
diff --git a/apps/production/src/project/project.service.ts b/apps/production/src/project/project.service.ts
index f40d9bd24..06035ae6c 100644
--- a/apps/production/src/project/project.service.ts
+++ b/apps/production/src/project/project.service.ts
@@ -9,7 +9,7 @@ import {
NotFoundException,
} from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
-import { Repository } from 'typeorm'
+import { FindOneOptions, Repository } from 'typeorm'
import { customAlphabet } from 'nanoid'
import handlebars from 'handlebars'
import puppeteer from 'puppeteer'
@@ -1389,18 +1389,17 @@ export class ProjectService {
}
}
- // Monitoring
- async createMonitorGroup(
- projectId: string,
- createMonitorGroupDto: CreateMonitorGroupDto,
- ) {
- return this.monitorGroupRepository.save({
- ...createMonitorGroupDto,
+ async createMonitorGroup(projectId: string, { name }: CreateMonitorGroupDto) {
+ const group = this.monitorGroupRepository.create({
+ name,
project: { id: projectId },
})
+
+ await this.monitorGroupRepository.save(group)
+
+ return group
}
- // Get all monitor groups for a specific project
async getMonitorGroupsByProjectId(
projectId: string,
): Promise<MonitorGroupEntity[]> {
@@ -1409,7 +1408,6 @@ export class ProjectService {
})
}
- // Get a monitor group by ID
async getMonitorGroupById(
projectId: string,
monitorGroupId: string,
@@ -1432,7 +1430,6 @@ export class ProjectService {
// await this.monitorGroupRepository.update(monitorGroupId, updateMonitorGroupDto)
}
- // Delete a monitor group
async deleteMonitorGroup(
projectId: string,
monitorGroupId: string,
@@ -1458,22 +1455,63 @@ export class ProjectService {
async findMonitorGroup(
id: string,
projectId: string,
+ options?: Omit<FindOneOptions<MonitorGroupEntity>, 'where'>,
): Promise<MonitorGroupEntity | undefined> {
return this.monitorGroupRepository.findOne({
where: {
id,
project: { id: projectId },
},
+ ...options,
})
}
- // Add a monitor to a monitor group
- async createMonitor(
- createMonitorHttpRequestDto: CreateMonitorHttpRequestDTO,
+ async findMonitorById(
+ id: string,
+ groupId: string,
+ projectId: string,
+ options?: Omit<FindOneOptions<MonitorEntity>, 'where'>,
+ ): Promise<MonitorEntity | undefined> {
+ return this.monitorRepository.findOne({
+ where: {
+ id,
+ group: {
+ id: groupId,
+ project: {
+ id: projectId,
+ },
+ },
+ },
+ ...options,
+ })
+ }
+
+ async createMonitorInGroup(
+ {
+ type,
+ name,
+ url,
+ interval,
+ retries,
+ retryInterval,
+ timeout,
+ acceptedStatusCodes,
+ description,
+ httpOptions,
+ }: CreateMonitorHttpRequestDTO,
group: string,
): Promise<MonitorEntity> {
const monitor = this.monitorRepository.create({
- ...createMonitorHttpRequestDto,
+ type,
+ name,
+ url,
+ interval,
+ retries,
+ retryInterval,
+ timeout,
+ acceptedStatusCodes,
+ description,
+ httpOptions,
group: { id: group },
})
@@ -1489,14 +1527,35 @@ export class ProjectService {
})
}
- // Update a monitor group
async updateMonitor(
monitorId: number,
- updateMonitorHttpRequestDto: UpdateMonitorHttpRequestDTO,
+ {
+ type,
+ name,
+ url,
+ interval,
+ retries,
+ retryInterval,
+ timeout,
+ acceptedStatusCodes,
+ description,
+ httpOptions,
+ }: UpdateMonitorHttpRequestDTO,
): Promise<any> {
await this.monitorRepository.update(
{ id: monitorId },
- updateMonitorHttpRequestDto,
+ {
+ type,
+ name,
+ url,
+ interval,
+ retries,
+ retryInterval,
+ timeout,
+ acceptedStatusCodes,
+ description,
+ httpOptions,
+ },
)
}
@@ -1533,8 +1592,6 @@ export class ProjectService {
async deleteHttpRequest(monitorId: number) {
const job = await this.monitorQueue.getJob(monitorId.toString())
- this.logger.debug(`Job ${JSON.stringify(job)}`)
- this.logger.debug(`Monitor Id: ${monitorId.toString()}`)
if (job) {
await job.remove()
}