diff --git a/docs/src/pages/tutorial/run-using-ping-method.md b/docs/src/pages/tutorial/run-using-ping-method.md index 5b909acfa..a445bfaed 100644 --- a/docs/src/pages/tutorial/run-using-ping-method.md +++ b/docs/src/pages/tutorial/run-using-ping-method.md @@ -24,23 +24,15 @@ probes: name: ping_test description: requesting icmp ping interval: 10 - requests: - - url: https://google.com - ping: true - - method: GET - url: https://reqres.in/api/users - alerts: - - query: response.status != 200 - message: Status code is not 200 - - query: response.time > 2000 - message: Request took more than 2 seconds + ping: + - uri: google.com ``` Let me explain this configuration a little bit: - This configuration uses Desktop notifications -- This probe configuration will do two requests: **Hit google.com using PING**. After PING success, it will **hit** [**https://reqres.in/api/users**](https://reqres.in/api/users) **using the GET method**. If by chance the first request fails, it will not proceed to the next request. -- This probe configuration will alert you if the status code is not 200, or the request took longer than two seconds +- This probe configuration will **hit google.com using PING** +- This probe configuration will alert you if ping request is not successful (200), or the request took longer than two seconds Save the configuration above as `monika.yaml` in your local machine and run `monika -c monika.yaml` command in your terminal inside the directory where you saved the configuration file. diff --git a/monika.example.yml b/monika.example.yml index 85441f2f1..d2428a6aa 100644 --- a/monika.example.yml +++ b/monika.example.yml @@ -33,12 +33,8 @@ probes: # name: ping_test # description: requesting icmp ping # interval: 10 -# requests: -# - url: http://google.com -# ping: true -# alerts: -# - assertion: response.status == 500 -# message: response status message +# ping: +# - uri: http://google.com # Configuration example for sending Multiple requests # Requests could be define in array to run for multiple requests diff --git a/src/components/logger/startup-message.ts b/src/components/logger/startup-message.ts index d62f17018..ba9c42924 100644 --- a/src/components/logger/startup-message.ts +++ b/src/components/logger/startup-message.ts @@ -98,6 +98,10 @@ function generateStartupMessage({ startupMessage += generateNotificationMessage(notifications) } + if (probes.some((p) => p.requests?.some((r) => r.ping))) { + startupMessage += generateDeprecatedPingMessage() + } + return startupMessage } @@ -118,6 +122,21 @@ function generateEmptyNotificationMessage(): string { }) } +function generateDeprecatedPingMessage(): string { + const message = `We are deprecating probe requests with flag "ping: true", please migrate to standalone probe https://monika.hyperjump.tech/guides/probes#ping-request` + return boxen(chalk.yellow(message), { + padding: 1, + margin: { + top: 2, + right: 1, + bottom: 2, + left: 1, + }, + borderStyle: 'bold', + borderColor: 'yellow', + }) +} + type GenerateConfigInfoMessageParams = { isFirstRun: boolean notificationTotal: number diff --git a/src/components/probe/prober/http/request.ts b/src/components/probe/prober/http/request.ts index 0911747dd..6b964d119 100644 --- a/src/components/probe/prober/http/request.ts +++ b/src/components/probe/prober/http/request.ts @@ -91,6 +91,9 @@ export async function httpRequest({ try { // is this a request for ping? if (newReq.ping === true) { + log.warn( + `PING ${renderedURL}: Requests with "ping: true" is deprecated, please migrate to standalone probe https://monika.hyperjump.tech/guides/probes#ping-request` + ) return icmpRequest({ host: renderedURL }) } diff --git a/src/components/probe/prober/icmp/request.ts b/src/components/probe/prober/icmp/request.ts index 41891d982..2491684b3 100644 --- a/src/components/probe/prober/icmp/request.ts +++ b/src/components/probe/prober/icmp/request.ts @@ -75,7 +75,6 @@ export async function icmpRequest( return processICMPRequestResult(icmpResp) } catch (error: unknown) { - console.error('icmp got error:', error) baseResponse.data = '' baseResponse.error = getErrorMessage(error) } diff --git a/src/monika-config-schema.json b/src/monika-config-schema.json index 50b9e3416..1817e0d04 100644 --- a/src/monika-config-schema.json +++ b/src/monika-config-schema.json @@ -246,6 +246,9 @@ "type": "object", "additionalProperties": false, "required": ["url"], + "patternProperties": { + "ping": { "type": "boolean" } + }, "properties": { "id": { "title": "Id", @@ -296,11 +299,6 @@ "alerts": { "$ref": "#/definitions/alerts" }, - "ping": { - "title": "Ping", - "type": "boolean", - "description": "If defined and to true, the request is an ICMP ping" - }, "allowUnauthorized": { "title": "AllowUnauthorized", "type": "boolean",