gatus
gatus copied to clipboard
feat(alerting): custom alert support endpoint errors
Summary
Fixes #840
- Updated
buildHTTPRequest
method inAlertProvider
to accept aresult
parameter. - Added support for including
[ENDPOINT_ERRORS]
in both the request body and URL, which will be replaced by the errors fromResult.Errors[]
. - Modified the
Send
method to pass theresult
object tobuildHTTPRequest
. - Adjusted
CreateExternalEndpointResult
to capture and store errors from query parameters. - This allows custom alerts to include detailed error information, enhancing the flexibility of alert notifications.
Usage
push the status of an external endpoint
curl -X POST -H "Authorization: Bearer 123456" "http://127.0.0.1:8080/api/v1/endpoints/core_ext-ep-test/external?success=false&error=xxxx"
custom alerts config
alerting:
custom:
url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxx
method: POST
headers:
Content-Type: application/json
body: |
{
"msgtype": "markdown",
"markdown": {
"content": "Gatus:\n <font color='warning'>[ALERT_TRIGGERED_OR_RESOLVED]</font>: [ENDPOINT_GROUP] - [ENDPOINT_NAME] - <font color='commen'>[ALERT_DESCRIPTION]</font>\n<font color='warning'>[ENDPOINT_ERRORS]</font>"
}
}
Checklist
- [x] Tested and/or added tests to validate that the changes work as intended, if applicable.
- [x] Updated documentation in
README.md
, if applicable.