mirror of
https://github.com/healthchecks/healthchecks.git
synced 2026-04-25 06:55:53 +03:00
[GH-ISSUE #784] [Feature] Add ability to send RESPONSE_BODY in webhook integration #551
Labels
No labels
bug
bug
bug
feature
good-first-issue
new integration
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/healthchecks#551
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@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?
@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)@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.@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.Mattermostclass,notifymethod, 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.
@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
@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.