Configuring Webhooks in OpenResty Edge
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.
Create a webhook in OpenResty Edge Admin
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.
Select “Webhooks”.
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.
Trigger the webhook
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.
Save it.
Check the webhook execution history
Now we will go to the “Webhooks” page and check the execution history.
Select “Webhooks”.
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.
What is OpenResty Edge
OpenResty Edge is our all-in-one gateway software for microservices and distributed traffic architectures. It combines traffic management, private CDN construction, API gateway, security, and more to help you easily build, manage, and protect modern applications. OpenResty Edge delivers industry-leading performance and scalability to meet the demanding needs of high concurrency, high load scenarios. It supports scheduling containerized application traffic such as K8s and manages massive domains, making it easy to meet the needs of large websites and complex applications.
If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!
About The Author
Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..
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.