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.

Embeded image

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.

Screenshot

First, we need to create a webhook. Enter the “Global Config” page.

Screenshot

Select “Webhooks”.

Screenshot

Create a webhook.

Screenshot

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.

Screenshot

We support many kinds of built-in events. We can also add more events upon user requests.

Screenshot

Select the “Gateway Server Offline” event here.

Screenshot

After clicking “Create”, the new webhook is ready now.

Screenshot

Trigger the webhook

Let’s try to drop off a gateway server to trigger the webhook.

Screenshot

We would use this server.

Screenshot

Go to the settings page.

Screenshot

Note that this server is online.

Screenshot

Drop off this server.

Screenshot

Save it.

Screenshot

Check the webhook execution history

Now we will go to the “Webhooks” page and check the execution history.

Screenshot

Select “Webhooks”.

Screenshot

Choose the “Detail” button.

Screenshot

We will see the webhook execution history. It means the triggered event has been sent successfully.

Screenshot

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!

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.