Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Post to webhook on failed health check #4039

Closed
carterbryden opened this issue Feb 25, 2021 · 4 comments
Closed

Feature Request: Post to webhook on failed health check #4039

carterbryden opened this issue Feb 25, 2021 · 4 comments
Labels
feature ⚙️ New feature or request
Milestone

Comments

@carterbryden
Copy link

This might be outside the scope of Caddy, but it would be fantastically useful if Caddy health checks could be configured to post to an arbitrary URL on failure (or maybe even success too).

Something like this in the JSON config for /apps/http/servers/routes/handle/reverse_proxy:

{
  "health_checks" : {
    //passive or active configs,
    "actions" : {
      "failure" : {
        "webhook_url": "your.apiurl.com/your-url"
      }
    }
  }
}

Ideally it would post some json to that webhook URL that would let the receiver identify the route, the datetime it failed, etc.

I think this could be really valuable for a lot of use cases (basically free uptime monitoring) and it feels like it would fit in well with a lot of other features that really make Caddy stand out in terms of practical convenience.

@francislavoie francislavoie added the feature ⚙️ New feature or request label Feb 25, 2021
@francislavoie
Copy link
Member

francislavoie commented Feb 25, 2021

Not a bad idea, but I'm not sure that specific config example would be what we'd want to go for - I think it would be better to find a solution that's more generalizable instead of only supporting webhooks.

I think this might fit into the realm of "event handling", where the reverse_proxy handler could emit an event that could be handled by some event.handler.* module, all this configured under an event app maybe. There's demand for events already such as #2344, and having a way to handle various kinds of situations would be quite powerful.

Anyways, not quite the same, but you can use the reverse_proxy's handle_response functionality right now, to handle 502 statuses (i.e. none of the upstreams are usable; unfortunately not if it's just a single one) with a reverse_proxy to your "webhook" endpoint; you can set headers with the context info. https://caddyserver.com/docs/json/apps/http/servers/routes/handle/reverse_proxy/#handle_response

@carterbryden
Copy link
Author

you can use the reverse_proxy's handle_response functionality

That sounds like it would cover my use case well enough actually, thanks for the tip.

As for event handling, I agree that would be a much better and more powerful means of accomplishing this idea and a number of others. The only reason I'd suggested something webhook specific was to try and keep the scope small with as much utility as possible. I'd much rather see an event handling system in the long run.

@mholt
Copy link
Member

mholt commented Mar 2, 2021

I also prefer the event handler module. That way any app can emit events and have it handled flexibily in a separate module dedicated to that.

@mholt
Copy link
Member

mholt commented Aug 31, 2022

Implemented in #4984

@mholt mholt closed this as completed Aug 31, 2022
@mholt mholt added this to the v2.6.0-beta.1 milestone Aug 31, 2022
@mholt mholt modified the milestones: v2.6.0-beta.1, v2.6.0 Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants