This tutorial will show you how to configure webhooks in OpenResty Edge. Webhooks can be triggered when an event of interest occurs, such as a gateway server offline event. Edge Admin will then send HTTP requests to your custom HTTP APIs automatically upon subscribed events.
Let’s go to a web console of OpenResty Edge. This is our sample deployment of the console. Every user would have their own deployment.
First, we need to create a webhook. Enter the “Global Config” page.
Create a webhook.
Here we create a webhook that can send an HTTP request to a custom API upon the Gateway Server Offline event. The custom API is implemented by users.
We support many kinds of built-in events. We can also add more events upon user requests.
Select the “Gateway Server Offline” event here.
After clicking “Create”, the new webhook is ready now.
Let’s try to drop off a gateway server to trigger the webhook.
We would use this server.
Go to the settings page.
Note that this server is online.
Drop off this server.
Now we will go to the “Webhooks” page and check the execution history.
Choose the “Detail” button.
We will see the webhook execution history. It means the triggered event has been sent successfully.
A server can go offline for various reasons, such as failures or anomalies. Gateway Server Offline events capture all these scenarios, not just when the server is manually marked offline in Edge Admin, as shown here.
If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!
Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.
OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.
As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.