[GH-ISSUE #784] [Feature] Add ability to send RESPONSE_BODY in webhook integration #551

Closed
opened 2026-02-25 23:42:50 +03:00 by kerem · 6 comments
Owner

Originally created by @boopzz on GitHub (Jan 31, 2023).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/784

We currently use Mattermost as our messaging system and use it for simple alerting also. Currently the Mattermost integration works but wont give the response body in a message. To give some more information with our scripts we send an error message in the body of our failed healthcheck which we'd like sent with the alert. I can see in the docs where we can use a webhook instead for the alert to Mattermost with some other placeholders.

It would be really cool to have another placeholder called $BODY or $RESPONSE_BODY that outputs the response body sent with the alert. Arguably not everyone would want this, especially if they are sending a log file to be viewed within the healthchecks webapp but thought it could be nice functionality should be fairly easy to implement.

Originally created by @boopzz on GitHub (Jan 31, 2023). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/784 We currently use Mattermost as our messaging system and use it for simple alerting also. Currently the Mattermost integration works but wont give the response body in a message. To give some more information with our scripts we send an error message in the body of our failed healthcheck which we'd like sent with the alert. I can see in the docs where we can use a webhook instead for the alert to Mattermost with some other placeholders. It would be really cool to have another placeholder called $BODY or $RESPONSE_BODY that outputs the response body sent with the alert. Arguably not everyone would want this, especially if they are sending a log file to be viewed within the healthchecks webapp but thought it could be nice functionality should be fairly easy to implement.
kerem closed this issue 2026-02-25 23:42:50 +03:00
Author
Owner

@boopzz commented on GitHub (Jan 31, 2023):

I'd like to try and help out and add this in myself as it feels like it should be a fairly quick thing but cant for the life of me find where the values are set. All the vars are fairly common words in the code base like CODE, STATUS, TAGS 😅 . Any pointers to where the current ones are?

<!-- gh-comment-id:1410068643 --> @boopzz commented on GitHub (Jan 31, 2023): I'd like to try and help out and add this in myself as it feels like it should be a fairly quick thing but cant for the life of me find where the values are set. All the vars are fairly common words in the code base like CODE, STATUS, TAGS 😅 . Any pointers to where the current ones are?
Author
Owner

@boopzz commented on GitHub (Jan 31, 2023):

I think the functionality is there but not surfaced yet? github.com/healthchecks/healthchecks@e5e369257c/templates/integrations/webhook_form.html (L224)

<!-- gh-comment-id:1410238540 --> @boopzz commented on GitHub (Jan 31, 2023): I think the functionality is there but not surfaced yet? https://github.com/healthchecks/healthchecks/blob/e5e369257c7e784ae4c0784c2f4390f0f3b57c6f/templates/integrations/webhook_form.html#L224
Author
Owner

@cuu508 commented on GitHub (Jan 31, 2023):

A $BODY placeholder was implemented in https://github.com/healthchecks/healthchecks/pull/708.

I'm not sure though how well it would work with Mattermost notifications – $BODY contains raw request body, and if you do something like {"body": "$BODY"}, you would likely run into character escaping issues.

<!-- gh-comment-id:1410244833 --> @cuu508 commented on GitHub (Jan 31, 2023): A $BODY placeholder was implemented in https://github.com/healthchecks/healthchecks/pull/708. I'm not sure though how well it would work with Mattermost notifications – $BODY contains raw request body, and if you do something like `{"body": "$BODY"}`, you would likely run into character escaping issues.
Author
Owner

@cuu508 commented on GitHub (Jan 31, 2023):

Currently, the Slack and Mattermost integrations use the same message template: slack_message.json.

The Slack integration already includes last ping body in the notification (implemented in #735), so the template already supports this. The missing part, to enable it for Mattermost, is in the hc.api.transports.Mattermost class, notify method, fetch the body and pass it as an argument when rendering the template. Here's how the Slack integration does it: github.com/healthchecks/healthchecks@091310f34b/hc/api/transports.py (L351)

And the next step would be to test it and see if the last ping body looks OK in Mattermost UIs.

<!-- gh-comment-id:1410255137 --> @cuu508 commented on GitHub (Jan 31, 2023): Currently, the Slack and Mattermost integrations use the same message template: [slack_message.json](https://github.com/healthchecks/healthchecks/blob/master/templates/integrations/slack_message.json). The Slack integration already includes last ping body in the notification (implemented in #735), so the template already supports this. The missing part, to enable it for Mattermost, is in the `hc.api.transports.Mattermost` class, `notify` method, fetch the body and pass it as an argument when rendering the template. Here's how the Slack integration does it: https://github.com/healthchecks/healthchecks/blob/091310f34b78434655a42ffab879d726022e13a2/hc/api/transports.py#L351 And the next step would be to test it and see if the last ping body looks OK in Mattermost UIs.
Author
Owner

@boopzz commented on GitHub (Jan 31, 2023):

ok cool, might it be worth surfacing a checkbox on the form to say if you want it passed or not? I guess some people would want to send a bunch of logs to the UI but not forced into sending them via the notification

<!-- gh-comment-id:1410257586 --> @boopzz commented on GitHub (Jan 31, 2023): ok cool, might it be worth surfacing a checkbox on the form to say if you want it passed or not? I guess some people would want to send a bunch of logs to the UI but not forced into sending them via the notification
Author
Owner

@cuu508 commented on GitHub (Jan 31, 2023):

Potentially yes, but I'd say only if and when end users specifically request it. The Slack integration includes the last ping body with no opt-out option, and there have been no complaints.

<!-- gh-comment-id:1410261196 --> @cuu508 commented on GitHub (Jan 31, 2023): Potentially yes, but I'd say only if and when end users specifically request it. The Slack integration includes the last ping body with no opt-out option, and there have been no complaints.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#551
No description provided.