Repository: hyperjumptech/monika
Pull request #1111 (2023-08-31 04:12:28)

Refactor: Make the Probe Result a Mandatory Type
# Monika Pull Request (PR)

## What feature/issue does this PR add
Currently, the probe result is an optional type and http and tls prober does not return the result. To make it predictable and prevents bug in the future, the probe result must be mandatory

## How did you implement / how did you fix it
Make the probe result a mandatory type and add the result to the http and tls prober


## How to test
1. Run Monika as usual
2. Run the test


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) Report
> Merging [#1111](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) (4300012) into [main](https://app.codecov.io/gh/hyperjumptech/monika/commit/8a808fc7599ea8a1892000868ee6eeff3f66d1f0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) (8a808fc) will **increase** coverage by `0.02%`.
> The diff coverage is `82.14%`.

> :exclamation: Current head 4300012 differs from pull request most recent head d6d7beb. Consider uploading reports for the commit d6d7beb to get more accurate results

```diff
@@            Coverage Diff             @@
##             main    #1111      +/-   ##
==========================================
+ Coverage   60.44%   60.47%   +0.02%     
==========================================
  Files         113      113              
  Lines        3216     3218       +2     
  Branches      635      635              
==========================================
+ Hits         1944     1946       +2     
  Misses        990      990              
  Partials      282      282              
```


| [Files Changed](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) | Coverage Δ | |
|---|---|---|
| [src/components/probe/prober/http/request.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL2h0dHAvcmVxdWVzdC50cw==) | `66.66% <ø> (+0.34%)` | :arrow_up: |
| [src/components/probe/prober/icmp/request.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL2ljbXAvcmVxdWVzdC50cw==) | `15.38% <ø> (ø)` | |
| [src/plugins/metrics/prometheus/collector.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL3BsdWdpbnMvbWV0cmljcy9wcm9tZXRoZXVzL2NvbGxlY3Rvci50cw==) | `64.00% <50.00%> (ø)` | |
| [src/components/probe/prober/mariadb/request.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL21hcmlhZGIvcmVxdWVzdC50cw==) | `66.66% <66.66%> (ø)` | |
| [src/components/probe/prober/mongo/request.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL21vbmdvL3JlcXVlc3QudHM=) | `82.97% <66.66%> (ø)` | |
| [src/components/probe/prober/postgres/request.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL3Bvc3RncmVzL3JlcXVlc3QudHM=) | `77.14% <66.66%> (ø)` | |
| [src/components/probe/prober/redis/request.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL3JlZGlzL3JlcXVlc3QudHM=) | `78.78% <66.66%> (ø)` | |
| [src/components/probe/prober/http/index.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL2h0dHAvaW5kZXgudHM=) | `79.31% <100.00%> (ø)` | |
| [src/components/probe/prober/mariadb/index.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL21hcmlhZGIvaW5kZXgudHM=) | `87.50% <100.00%> (ø)` | |
| [src/components/probe/prober/mongo/index.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvcHJvYmVyL21vbmdvL2luZGV4LnRz) | `91.66% <100.00%> (ø)` | |
| ... and [6 more](https://app.codecov.io/gh/hyperjumptech/monika/pull/1111?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) | |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech)

haricnugraha: > can you please check that this config works? I have an issue with non-http probes working:
> 
> ```yaml
> probes:
>   - id: 'psql-1'
>     name: 'psql-test'
>     postgres:
>       - uri: 'postgresql://user:password@172.17.0.1:5432'
>     alerts:
>       - assertion: response.status < 200 or response.status > 299
>         message: HTTP Status is not 200
>       - assertion: response.time > 2000
>         message: Response time is more than 2000ms
>     incidentThreshold: 3
>     recoveryThreshold: 3
>     
>     notifications:
>   - id: desktop
>     type: desktop
> ```

I think that is related to the issue on the PR https://github.com/hyperjumptech/monika/pull/1113. Will check once the PR 1113 got merged. 
sapiderman: > > can you please check that this config works? I have an issue with non-http probes working:
> > ```yaml
> > probes:
> >   - id: 'psql-1'
> >     name: 'psql-test'
> >     postgres:
> >       - uri: 'postgresql://user:password@172.17.0.1:5432'
> >     alerts:
> >       - assertion: response.status < 200 or response.status > 299
> >         message: HTTP Status is not 200
> >       - assertion: response.time > 2000
> >         message: Response time is more than 2000ms
> >     incidentThreshold: 3
> >     recoveryThreshold: 3
> >     
> >     notifications:
> >   - id: desktop
> >     type: desktop
> > ```
> 
> I think that is related to the issue on the PR #1113. Will check once the PR 1113 got merged.

Will merge 1113 and try again. thank you

Patch:
diff --git a/src/components/probe/prober/http/index.ts b/src/components/probe/prober/http/index.ts
index 463162bc..0cf88886 100644
--- a/src/components/probe/prober/http/index.ts
+++ b/src/components/probe/prober/http/index.ts
@@ -29,7 +29,7 @@ import events from '../../../../events'
 import type { Notification } from '@hyperjumptech/monika-notification'
 import type { Probe } from '../../../../interfaces/probe'
 import type { ProbeRequestResponse } from '../../../../interfaces/request'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import validateResponse from '../../../../plugins/validate-response'
 import { getEventEmitter } from '../../../../utils/events'
 import { log } from '../../../../utils/pino'
@@ -136,8 +136,8 @@ async function probeHTTP(
       // Set request result value
       const isDown = statuses.some((item) => item.state === 'DOWN')
       probeRes.result = isDown
-        ? ProbeRequestResult.failed
-        : ProbeRequestResult.success
+        ? probeRequestResult.failed
+        : probeRequestResult.success
 
       eventEmitter.emit(events.probe.response.received, {
         probe,
diff --git a/src/components/probe/prober/http/request.ts b/src/components/probe/prober/http/request.ts
index d829ddd2..61adc529 100644
--- a/src/components/probe/prober/http/request.ts
+++ b/src/components/probe/prober/http/request.ts
@@ -26,8 +26,9 @@ import * as Handlebars from 'handlebars'
 import FormData from 'form-data'
 import YAML from 'yaml'
 import {
-  ProbeRequestResponse,
-  RequestConfig,
+  type ProbeRequestResponse,
+  type RequestConfig,
+  probeRequestResult,
 } from '../../../../interfaces/request'
 import * as qs from 'querystring'
 
@@ -165,7 +166,7 @@ export async function httpRequest({
       status,
       headers,
       responseTime,
-
+      result: probeRequestResult.success,
       isProbeResponsive: true,
     }
   } catch (error: any) {
@@ -180,7 +181,7 @@ export async function httpRequest({
         status: error?.response?.status,
         headers: error?.response?.headers,
         responseTime,
-
+        result: probeRequestResult.success,
         isProbeResponsive: true, // http status received, so connection ok
       }
     }
@@ -196,7 +197,7 @@ export async function httpRequest({
         status,
         headers: '',
         responseTime,
-
+        result: probeRequestResult.failed,
         isProbeResponsive: false,
         errMessage: error?.code,
       }
@@ -209,7 +210,7 @@ export async function httpRequest({
       status: error.code || 'Unknown error',
       headers: '',
       responseTime,
-
+      result: probeRequestResult.failed,
       isProbeResponsive: false,
       errMessage: error.code || 'Unknown error',
     }
diff --git a/src/components/probe/prober/icmp/request.ts b/src/components/probe/prober/icmp/request.ts
index fd5f6402..d61be97c 100644
--- a/src/components/probe/prober/icmp/request.ts
+++ b/src/components/probe/prober/icmp/request.ts
@@ -25,7 +25,7 @@
 import { sendPing } from '../../../../utils/ping'
 import {
   ProbeRequestResponse,
-  ProbeRequestResult,
+  probeRequestResult,
 } from '../../../../interfaces/request'
 
 type icmpParams = {
@@ -57,7 +57,7 @@ export async function icmpRequest(
     data: '',
     body: '',
     status: 0,
-    result: ProbeRequestResult.failed,
+    result: probeRequestResult.failed,
     headers: '',
     responseTime: 0,
     isProbeResponsive: false,
@@ -97,8 +97,8 @@ export function processICMPRequestResult(
     data: params.output, // map output to response data
     status: params.isAlive ? 200 : 0, // TO IMPROVE: this is a monkey patch to map ping return status to http status. Should not need it!
     result: params.isAlive
-      ? ProbeRequestResult.success
-      : ProbeRequestResult.failed,
+      ? probeRequestResult.success
+      : probeRequestResult.failed,
     body: msg,
     headers: {},
     responseTime: params.average || 0,
diff --git a/src/components/probe/prober/mariadb/index.ts b/src/components/probe/prober/mariadb/index.ts
index d67df3f8..b0f6c060 100644
--- a/src/components/probe/prober/mariadb/index.ts
+++ b/src/components/probe/prober/mariadb/index.ts
@@ -1,6 +1,6 @@
 import { BaseProber, type ProbeResult } from '../'
 import type { MariaDB } from '../../../../interfaces/probe'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import { mariaRequest } from './request'
 
 export class MariaDBProber extends BaseProber {
@@ -79,7 +79,7 @@ export async function probeMariaDB({
       password,
     })
     const { body, responseTime, result } = requestResponse
-    const isAlertTriggered = result !== ProbeRequestResult.success
+    const isAlertTriggered = result !== probeRequestResult.success
     const timeNow = new Date().toISOString()
     const logMessage = `${timeNow} ${checkOrder} id:${id} ${databaseText}:${host}:${port} ${responseTime}ms msg:${body}`
 
diff --git a/src/components/probe/prober/mariadb/request.ts b/src/components/probe/prober/mariadb/request.ts
index 7644f9a2..f59b1631 100644
--- a/src/components/probe/prober/mariadb/request.ts
+++ b/src/components/probe/prober/mariadb/request.ts
@@ -23,7 +23,7 @@
  **********************************************************************************/
 
 import type { ProbeRequestResponse } from '../../../../interfaces/request'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import { differenceInMilliseconds } from 'date-fns'
 import { createConnection } from 'mariadb'
 
@@ -44,7 +44,7 @@ export async function mariaRequest(
     data: '',
     body: '',
     status: 0,
-    result: ProbeRequestResult.unknown,
+    result: probeRequestResult.unknown,
     headers: '',
     responseTime: 0,
     isProbeResponsive: false,
@@ -63,7 +63,7 @@ export async function mariaRequest(
   } catch (error: any) {
     baseResponse.body = error.message
     baseResponse.errMessage = error
-    baseResponse.result = ProbeRequestResult.failed
+    baseResponse.result = probeRequestResult.failed
     isConnected = false
   }
 
@@ -74,7 +74,7 @@ export async function mariaRequest(
     baseResponse.responseTime = duration
     baseResponse.body = 'database ok'
     baseResponse.status = 200
-    baseResponse.result = ProbeRequestResult.success
+    baseResponse.result = probeRequestResult.success
     baseResponse.isProbeResponsive = true
   }
 
diff --git a/src/components/probe/prober/mongo/index.ts b/src/components/probe/prober/mongo/index.ts
index 7a762e7d..92ace91f 100644
--- a/src/components/probe/prober/mongo/index.ts
+++ b/src/components/probe/prober/mongo/index.ts
@@ -1,6 +1,6 @@
 import * as mongodbURI from 'mongodb-uri'
 import { BaseProber, type ProbeResult } from '..'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import type { Mongo } from '../../../../interfaces/probe'
 import { mongoRequest } from './request'
 
@@ -80,7 +80,7 @@ export async function probeMongo({
       password,
     })
     const { body, responseTime, result } = requestResponse
-    const isAlertTriggered = result !== ProbeRequestResult.success
+    const isAlertTriggered = result !== probeRequestResult.success
     const timeNow = new Date().toISOString()
     const logMessage = `${timeNow} ${checkOrder} id:${id} mongo:${host}:${port} ${responseTime}ms msg:${body}`
 
diff --git a/src/components/probe/prober/mongo/request.ts b/src/components/probe/prober/mongo/request.ts
index c926b1ce..f2c6edee 100644
--- a/src/components/probe/prober/mongo/request.ts
+++ b/src/components/probe/prober/mongo/request.ts
@@ -24,7 +24,7 @@
 
 import { MongoClient } from 'mongodb'
 import * as mongodbURI from 'mongodb-uri'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import type { ProbeRequestResponse } from '../../../../interfaces/request'
 import { differenceInMilliseconds } from 'date-fns'
 
@@ -55,7 +55,7 @@ export async function mongoRequest(
     data: '',
     body: '',
     status: 0,
-    result: ProbeRequestResult.unknown,
+    result: probeRequestResult.unknown,
     headers: '',
     responseTime: 0,
     isProbeResponsive: false,
@@ -69,10 +69,10 @@ export async function mongoRequest(
     baseResponse.responseTime = duration
     baseResponse.body = result.message
     baseResponse.status = 200
-    baseResponse.result = ProbeRequestResult.success
+    baseResponse.result = probeRequestResult.success
     baseResponse.isProbeResponsive = true
   } else {
-    baseResponse.result = ProbeRequestResult.failed
+    baseResponse.result = probeRequestResult.failed
     baseResponse.body = result.message
     baseResponse.errMessage = result.message
   }
diff --git a/src/components/probe/prober/postgres/index.ts b/src/components/probe/prober/postgres/index.ts
index 3860ac7b..9642c178 100644
--- a/src/components/probe/prober/postgres/index.ts
+++ b/src/components/probe/prober/postgres/index.ts
@@ -1,7 +1,7 @@
 import { parse } from 'pg-connection-string'
 import { BaseProber, type ProbeResult } from '..'
 import type { Postgres } from '../../../../interfaces/probe'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import { postgresRequest } from './request'
 
 export class PostgresProber extends BaseProber {
@@ -75,7 +75,7 @@ export async function probePostgres({
     const { host, port } = postgresConnectionDetails
     const requestResponse = await postgresRequest(postgresConnectionDetails)
     const { body, responseTime, result } = requestResponse
-    const isAlertTriggered = result !== ProbeRequestResult.success
+    const isAlertTriggered = result !== probeRequestResult.success
     const timeNow = new Date().toISOString()
     const logMessage = `${timeNow} ${checkOrder} id:${id} postgres:${host}:${port} ${responseTime}ms msg:${body}`
 
diff --git a/src/components/probe/prober/postgres/request.ts b/src/components/probe/prober/postgres/request.ts
index 177ea533..14924b2c 100644
--- a/src/components/probe/prober/postgres/request.ts
+++ b/src/components/probe/prober/postgres/request.ts
@@ -24,7 +24,7 @@
 
 import { Pool } from 'pg'
 import type { ProbeRequestResponse } from '../../../../interfaces/request'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import { differenceInMilliseconds } from 'date-fns'
 
 export type PostgresParam = {
@@ -52,7 +52,7 @@ export async function postgresRequest(
     status: 0,
     headers: '',
     responseTime: 0,
-    result: ProbeRequestResult.unknown,
+    result: probeRequestResult.unknown,
     isProbeResponsive: false,
   }
   const startTime = new Date()
@@ -64,10 +64,10 @@ export async function postgresRequest(
     baseResponse.responseTime = duration
     baseResponse.body = result.message
     baseResponse.status = 200
-    baseResponse.result = ProbeRequestResult.success
+    baseResponse.result = probeRequestResult.success
     baseResponse.isProbeResponsive = result.isAlive
   } else {
-    baseResponse.result = ProbeRequestResult.failed
+    baseResponse.result = probeRequestResult.failed
     baseResponse.body = result.message
     baseResponse.errMessage = result.message
   }
diff --git a/src/components/probe/prober/redis/index.ts b/src/components/probe/prober/redis/index.ts
index ef4c1579..dbf5df8b 100644
--- a/src/components/probe/prober/redis/index.ts
+++ b/src/components/probe/prober/redis/index.ts
@@ -1,7 +1,7 @@
 import parse from 'url-parse'
 import { BaseProber, type ProbeResult } from '..'
 import type { Redis } from '../../../../interfaces/probe'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import { redisRequest } from './request'
 
 export class RedisProber extends BaseProber {
@@ -80,7 +80,7 @@ export async function probeRedis({
       uri,
     })
     const { body, responseTime, result } = requestResponse
-    const isAlertTriggered = result !== ProbeRequestResult.success
+    const isAlertTriggered = result !== probeRequestResult.success
     const timeNow = new Date().toISOString()
 
     // parse uri for logMessage(host:port)
diff --git a/src/components/probe/prober/redis/request.ts b/src/components/probe/prober/redis/request.ts
index 553be5d3..7d04df5f 100644
--- a/src/components/probe/prober/redis/request.ts
+++ b/src/components/probe/prober/redis/request.ts
@@ -26,7 +26,7 @@ import { createClient } from 'redis'
 import type { ProbeRequestResponse } from '../../../../interfaces/request'
 import { differenceInMilliseconds } from 'date-fns'
 import type { Redis } from '../../../../interfaces/probe'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 
 type RedisResult = {
   isAlive: boolean // If redis responds to PING/commands
@@ -49,7 +49,7 @@ export async function redisRequest(
     status: 0,
     headers: '',
     responseTime: 0,
-    result: ProbeRequestResult.unknown,
+    result: probeRequestResult.unknown,
     isProbeResponsive: false,
   }
   const startTime = new Date()
@@ -62,10 +62,10 @@ export async function redisRequest(
     baseResponse.body = result.message
     baseResponse.status = 200
     baseResponse.isProbeResponsive = true
-    baseResponse.result = ProbeRequestResult.success
+    baseResponse.result = probeRequestResult.success
   } else {
     baseResponse.body = result.message
-    baseResponse.result = ProbeRequestResult.failed
+    baseResponse.result = probeRequestResult.failed
     baseResponse.errMessage = result.message
   }
 
diff --git a/src/components/probe/prober/socket/index.ts b/src/components/probe/prober/socket/index.ts
index b500daa5..40b16cbd 100644
--- a/src/components/probe/prober/socket/index.ts
+++ b/src/components/probe/prober/socket/index.ts
@@ -1,5 +1,5 @@
 import { BaseProber, type ProbeResult } from '..'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import type { Socket } from '../../../../interfaces/probe'
 import { tcpRequest } from './request'
 
@@ -58,7 +58,7 @@ export async function probeSocket({
   const url = `${host}:${port}`
   const requestResponse = await tcpRequest({ host, port, data })
   const { body, responseTime, result } = requestResponse
-  const isAlertTriggered = result !== ProbeRequestResult.success
+  const isAlertTriggered = result !== probeRequestResult.success
   const timeNow = new Date().toISOString()
   const logMessage = `${timeNow} ${checkOrder} id:${id} tcp:${url} ${responseTime}ms msg:${body}`
 
diff --git a/src/components/probe/prober/socket/request.ts b/src/components/probe/prober/socket/request.ts
index fc394b5f..40d39026 100644
--- a/src/components/probe/prober/socket/request.ts
+++ b/src/components/probe/prober/socket/request.ts
@@ -24,7 +24,7 @@
 
 import net from 'net'
 import { differenceInMilliseconds } from 'date-fns'
-import { ProbeRequestResult } from '../../../../interfaces/request'
+import { probeRequestResult } from '../../../../interfaces/request'
 import type { ProbeRequestResponse } from '../../../../interfaces/request'
 
 type TCPRequest = {
@@ -57,8 +57,8 @@ export async function tcpRequest(
     status: tcpResp.status === 'DOWN' ? 0 : 200, // set to 0 if down, and 200 if ok
     result:
       tcpResp.status === 'DOWN'
-        ? ProbeRequestResult.failed
-        : ProbeRequestResult.success,
+        ? probeRequestResult.failed
+        : probeRequestResult.success,
     headers: {},
     responseTime: tcpResp.duration,
 
diff --git a/src/interfaces/request.ts b/src/interfaces/request.ts
index 5361bda9..4dfcb42b 100644
--- a/src/interfaces/request.ts
+++ b/src/interfaces/request.ts
@@ -38,7 +38,7 @@ export type RequestTypes =
   | 'postgres'
 
 // The success/failure result of a probe
-export enum ProbeRequestResult {
+export enum probeRequestResult {
   failed = 0,
   success = 1,
   unknown = 2,
@@ -57,7 +57,7 @@ export interface ProbeRequestResponse<T = any> {
   isProbeResponsive: boolean // did the command/request response to requests/queries?
   errMessage?: string // any error message from drivers
 
-  result?: ProbeRequestResult // did the probe succeed or fail?
+  result: probeRequestResult // did the probe succeed or fail?
 }
 
 // ProbeRequest is used to define the requests that is being made.
diff --git a/src/jobs/tls-check.ts b/src/jobs/tls-check.ts
index 4a44cfda..e6a889e1 100644
--- a/src/jobs/tls-check.ts
+++ b/src/jobs/tls-check.ts
@@ -29,6 +29,7 @@ import { checkTLS, getHostname } from '../components/tls-checker'
 import type { Notification } from '@hyperjumptech/monika-notification'
 import type { ValidatedResponse } from '../plugins/validate-response'
 import { log } from '../utils/pino'
+import { probeRequestResult } from '../interfaces/request'
 
 type SendTLSErrorNotificationProps = {
   hostname: string
@@ -101,6 +102,7 @@ function sendTLSErrorNotification({
         data: {},
         body: {},
         headers: {},
+        result: probeRequestResult.success,
         isProbeResponsive: true,
       },
     }
diff --git a/src/plugins/metrics/prometheus/collector.ts b/src/plugins/metrics/prometheus/collector.ts
index 841d9e5f..9e1a5276 100644
--- a/src/plugins/metrics/prometheus/collector.ts
+++ b/src/plugins/metrics/prometheus/collector.ts
@@ -30,7 +30,7 @@ import {
   Counter,
 } from 'prom-client'
 import type { Probe } from '../../../interfaces/probe'
-import { ProbeRequestResult } from '../../../interfaces/request'
+import { probeRequestResult } from '../../../interfaces/request'
 import type { ProbeRequestResponse } from '../../../interfaces/request'
 
 type PrometheusCustomCollector = {
@@ -140,7 +140,7 @@ export class PrometheusCollector {
     const request = requests[requestIndex]
     const { method, url } = request
     const { headers, responseTime, status } = response
-    const result = response.result ?? ProbeRequestResult.unknown
+    const result = response.result ?? probeRequestResult.unknown
     const milliSecond = 1000
     const responseTimeInSecond = responseTime / milliSecond ?? 0
     const responseSizeBytes = Number(headers['content-length'])


Test patch:
diff --git a/src/components/notification/__tests__/alert-message.test.ts b/src/components/notification/__tests__/alert-message.test.ts
index 95461e55..64987d59 100644
--- a/src/components/notification/__tests__/alert-message.test.ts
+++ b/src/components/notification/__tests__/alert-message.test.ts
@@ -22,10 +22,11 @@
  * SOFTWARE.                                                                      *
  **********************************************************************************/
 
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import { format, subDays } from 'date-fns'
 import { resetContext, setContext } from '../../../context'
 import { getMessageForAlert } from '../alert-message'
+import { probeRequestResult } from '../../../interfaces/request'
 
 afterEach(() => {
   resetContext()
@@ -52,6 +53,7 @@ describe('Alert message', () => {
           status: 404,
           headers: '',
           responseTime: 1000,
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       })
@@ -81,6 +83,7 @@ describe('Alert message', () => {
           status: 404,
           headers: '',
           responseTime: 1000,
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       })
@@ -117,6 +120,7 @@ describe('Alert message', () => {
           status: 404,
           headers: '',
           responseTime: 1000,
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       })
@@ -168,6 +172,7 @@ describe('Alert message', () => {
           status: 404,
           headers: '',
           responseTime: 1000,
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       })
diff --git a/src/components/probe/prober/mariadb/index.test.ts b/src/components/probe/prober/mariadb/index.test.ts
index 945979bb..6bc13104 100644
--- a/src/components/probe/prober/mariadb/index.test.ts
+++ b/src/components/probe/prober/mariadb/index.test.ts
@@ -1,7 +1,10 @@
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import sinon from 'sinon'
 import { probeMariaDB } from '.'
-import { ProbeRequestResponse } from '../../../../interfaces/request'
+import {
+  type ProbeRequestResponse,
+  probeRequestResult,
+} from '../../../../interfaces/request'
 import * as request from './request'
 
 let mariaDBRequestStub: sinon.SinonStub
@@ -18,6 +21,7 @@ describe('Maria DB/MySQL Prober', () => {
           status: 200,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -164,6 +168,7 @@ describe('Maria DB/MySQL Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
diff --git a/src/components/probe/prober/mongo/index.test.ts b/src/components/probe/prober/mongo/index.test.ts
index a18f548f..7b8ace35 100644
--- a/src/components/probe/prober/mongo/index.test.ts
+++ b/src/components/probe/prober/mongo/index.test.ts
@@ -1,7 +1,10 @@
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import sinon from 'sinon'
 import { probeMongo } from '.'
-import { ProbeRequestResponse } from '../../../../interfaces/request'
+import {
+  type ProbeRequestResponse,
+  probeRequestResult,
+} from '../../../../interfaces/request'
 import * as request from './request'
 
 let mongoRequestStub: sinon.SinonStub
@@ -18,6 +21,7 @@ describe('MongoDB Prober', () => {
           status: 200,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -95,6 +99,7 @@ describe('MongoDB Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -132,6 +137,7 @@ describe('MongoDB Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
diff --git a/src/components/probe/prober/postgres/index.test.ts b/src/components/probe/prober/postgres/index.test.ts
index f4d80a4c..f295df07 100644
--- a/src/components/probe/prober/postgres/index.test.ts
+++ b/src/components/probe/prober/postgres/index.test.ts
@@ -1,7 +1,10 @@
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import sinon from 'sinon'
 import { probePostgres } from '.'
-import { ProbeRequestResponse } from '../../../../interfaces/request'
+import {
+  type ProbeRequestResponse,
+  probeRequestResult,
+} from '../../../../interfaces/request'
 import * as request from './request'
 
 let postgresRequestStub: sinon.SinonStub
@@ -18,6 +21,7 @@ describe('PostgreSQL Prober', () => {
           status: 200,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -99,6 +103,7 @@ describe('PostgreSQL Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -138,6 +143,7 @@ describe('PostgreSQL Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
diff --git a/src/components/probe/prober/redis/redis.test.ts b/src/components/probe/prober/redis/redis.test.ts
index 58346b3e..2125973b 100644
--- a/src/components/probe/prober/redis/redis.test.ts
+++ b/src/components/probe/prober/redis/redis.test.ts
@@ -1,7 +1,10 @@
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import sinon from 'sinon'
 import { probeRedis } from '.'
-import { ProbeRequestResponse } from '../../../../interfaces/request'
+import {
+  type ProbeRequestResponse,
+  probeRequestResult,
+} from '../../../../interfaces/request'
 import * as request from './request'
 
 let redisPingStub: sinon.SinonStub
@@ -18,6 +21,7 @@ describe('Redis Prober', () => {
           status: 200,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -108,6 +112,7 @@ describe('Redis Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
diff --git a/src/components/probe/prober/socket/index.test.ts b/src/components/probe/prober/socket/index.test.ts
index d1201a91..77d3229b 100644
--- a/src/components/probe/prober/socket/index.test.ts
+++ b/src/components/probe/prober/socket/index.test.ts
@@ -1,7 +1,10 @@
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import sinon from 'sinon'
 import { probeSocket } from '.'
-import { ProbeRequestResponse } from '../../../../interfaces/request'
+import {
+  type ProbeRequestResponse,
+  probeRequestResult,
+} from '../../../../interfaces/request'
 import * as request from './request'
 
 let tcpRequestStub: sinon.SinonStub
@@ -18,6 +21,7 @@ describe('TCP Prober', () => {
           status: 200,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
@@ -61,6 +65,7 @@ describe('TCP Prober', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         }
       })
diff --git a/src/plugins/metrics/prometheus/collector.test.ts b/src/plugins/metrics/prometheus/collector.test.ts
index b3abcc17..1d7ec93a 100644
--- a/src/plugins/metrics/prometheus/collector.test.ts
+++ b/src/plugins/metrics/prometheus/collector.test.ts
@@ -24,7 +24,10 @@
 
 import { expect } from '@oclif/test'
 import type { Probe } from '../../../interfaces/probe'
-import type { ProbeRequestResponse } from '../../../interfaces/request'
+import {
+  probeRequestResult,
+  type ProbeRequestResponse,
+} from '../../../interfaces/request'
 import { PrometheusCollector } from './collector'
 
 type ProbeResult = {
@@ -75,6 +78,7 @@ describe('Prometheus collector', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         },
       }
@@ -112,6 +116,7 @@ describe('Prometheus collector', () => {
           status: 0,
           headers: '',
           responseTime: 0,
+          result: probeRequestResult.failed,
           isProbeResponsive: false,
         },
       }
diff --git a/src/plugins/validate-response/__tests__/index.test.ts b/src/plugins/validate-response/__tests__/index.test.ts
index e64fd011..4d294322 100644
--- a/src/plugins/validate-response/__tests__/index.test.ts
+++ b/src/plugins/validate-response/__tests__/index.test.ts
@@ -22,9 +22,12 @@
  * SOFTWARE.                                                                      *
  **********************************************************************************/
 
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import validateResponse from '..'
-import { ProbeRequestResponse } from '../../../interfaces/request'
+import {
+  type ProbeRequestResponse,
+  probeRequestResult,
+} from '../../../interfaces/request'
 
 describe('validateResponse', () => {
   const mockedAlerts = [
@@ -52,6 +55,7 @@ describe('validateResponse', () => {
           responseTime: 20,
           headers: {},
           status: 300,
+          result: 1,
           isProbeResponsive: true,
         },
       },
@@ -66,6 +70,7 @@ describe('validateResponse', () => {
           responseTime: 20,
           headers: {},
           status: 300,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: true,
@@ -89,6 +94,7 @@ describe('validateResponse', () => {
           responseTime: 20,
           headers: {},
           status: 200,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: false,
@@ -104,6 +110,7 @@ describe('validateResponse', () => {
           responseTime: 20,
           headers: {},
           status: 200,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: true,
@@ -127,6 +134,7 @@ describe('validateResponse', () => {
           responseTime: 10,
           headers: {},
           status: 300,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: true,
@@ -142,6 +150,7 @@ describe('validateResponse', () => {
           responseTime: 10,
           headers: {},
           status: 300,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: false,
@@ -165,6 +174,7 @@ describe('validateResponse', () => {
           responseTime: 10,
           headers: {},
           status: 200,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: false,
@@ -180,6 +190,7 @@ describe('validateResponse', () => {
           responseTime: 10,
           headers: {},
           status: 200,
+          result: 1,
           isProbeResponsive: true,
         },
         isAlertTriggered: false,
@@ -199,6 +210,9 @@ function generateMockedResponse(
     status,
     responseTime,
     headers: {},
+    result: isProbeResponsive
+      ? probeRequestResult.success
+      : probeRequestResult.failed,
     isProbeResponsive,
   }
 }
diff --git a/src/plugins/validate-response/checkers/__tests__/query-expression.test.ts b/src/plugins/validate-response/checkers/__tests__/query-expression.test.ts
index fdb13e18..08a9d2cb 100644
--- a/src/plugins/validate-response/checkers/__tests__/query-expression.test.ts
+++ b/src/plugins/validate-response/checkers/__tests__/query-expression.test.ts
@@ -22,8 +22,9 @@
  * SOFTWARE.                                                                      *
  **********************************************************************************/
 
-import { expect } from 'chai'
+import { expect } from '@oclif/test'
 import queryExpression from '../query-expression'
+import { probeRequestResult } from '../../../../interfaces/request'
 
 describe('queryExpression', () => {
   it('should handle response time query', () => {
@@ -33,6 +34,7 @@ describe('queryExpression', () => {
       status: 200,
       headers: {},
       responseTime: 150,
+      result: probeRequestResult.success,
       isProbeResponsive: true,
     }
 
@@ -48,6 +50,7 @@ describe('queryExpression', () => {
       status: 200,
       headers: {},
       responseTime: 200,
+      result: probeRequestResult.success,
       isProbeResponsive: true,
     }
 
@@ -63,6 +66,7 @@ describe('queryExpression', () => {
       status: 200,
       headers: { 'content-length': 2000 },
       responseTime: 200,
+      result: probeRequestResult.success,
       isProbeResponsive: true,
     }
 
@@ -78,6 +82,7 @@ describe('queryExpression', () => {
       status: 200,
       headers: { 'Content-Type': 'application/json' },
       responseTime: 200,
+      result: probeRequestResult.success,
       isProbeResponsive: true,
     }
 
@@ -100,6 +105,7 @@ describe('queryExpression', () => {
       body: {
         message: 'Hello',
       },
+      result: probeRequestResult.success,
       isProbeResponsive: true,
     }
 
diff --git a/test/components/notification.test.ts b/test/components/notification.test.ts
index a8ebb747..565908d5 100644
--- a/test/components/notification.test.ts
+++ b/test/components/notification.test.ts
@@ -27,6 +27,7 @@ import spies from 'chai-spies'
 import { sendAlerts } from '../../src/components/notification'
 import { channels } from '@hyperjumptech/monika-notification'
 import type { NotificationMessage } from '@hyperjumptech/monika-notification'
+import { probeRequestResult } from '../../src/interfaces/request'
 
 const { discord, mailgun, slack, smtp, telegram, webhook, whatsapp, lark } =
   channels
@@ -51,6 +52,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -84,6 +86,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -117,6 +120,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -151,6 +155,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -186,6 +191,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -226,6 +232,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -262,6 +269,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -315,6 +323,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -351,6 +360,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -384,6 +394,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -417,6 +428,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },
@@ -450,6 +462,7 @@ describe('send alerts', () => {
           status: 500,
           responseTime: 0,
           headers: {},
+          result: probeRequestResult.success,
           isProbeResponsive: true,
         },
       },