To configure a webhook in OpenResty Edge, open Global Config → Webhooks, create a webhook, and subscribe it to an event such as Gateway Server Offline. Edge Admin then sends an HTTP request to your own custom API automatically whenever that event fires. The Gateway Server Offline event covers any cause a server goes offline — whether Edge’s active health probing detects it down, the server itself hits an anomaly, or you take it offline manually in Edge Admin — so your alerting API catches every outage. This tutorial walks through creating, triggering, and verifying such a webhook. If you’d like to understand why event-driven webhook notifications beat polling-based monitoring in the first place, see our overview of the OpenResty Edge webhook mechanism.

OpenResty Edge webhook triggering an HTTP request to a custom API on a gateway server offline event

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.

OpenResty Edge Admin web console dashboard

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

Opening the Global Config page in OpenResty Edge Admin

Select “Webhooks”.

Selecting Webhooks under Global Config in OpenResty Edge

Create a webhook.

Creating a new webhook in OpenResty Edge Admin

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.

Configuring the webhook to send an HTTP request to a custom API on the Gateway Server Offline event

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

List of built-in webhook events available in OpenResty Edge

Select the “Gateway Server Offline” event here.

Selecting the Gateway Server Offline event for the webhook

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

The newly created gateway server offline webhook ready in Edge Admin

Trigger the webhook with a gateway server offline event

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

Preparing to drop off a gateway server to trigger the webhook

We would use this server.

Selecting the gateway server to take offline

Go to the settings page.

Opening the gateway server settings page in Edge Admin

Note that this server is online.

The gateway server currently showing as online

Drop off this server.

Marking the gateway server offline in its settings

Save it.

Saving the offline change to trigger the webhook

Check the webhook execution history

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

Navigating back to the Webhooks page to check execution history

Select “Webhooks”.

Selecting Webhooks to open the webhook list

Choose the “Detail” button.

Clicking the Detail button to view the webhook execution history

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

Webhook execution history confirming the offline event was sent to the custom API

Beyond the manual offline shown here, OpenResty Edge actively probes each gateway server with health checks, so the Gateway Server Offline event also fires when that probing detects a server down or the server itself hits an anomaly. For the operations thinking behind driving alerts and automation from these events, see OpenResty Edge Webhook: Event-Driven Gateway Notifications That Replace Polling.

FAQ

What events can trigger a webhook in OpenResty Edge?

OpenResty Edge supports many built-in events that a webhook can subscribe to, such as the Gateway Server Offline event used in this tutorial. If you need an event that isn’t built in yet, more events can be added on request. When a subscribed event fires, Edge Admin sends an HTTP request to the custom API you configured.

Does the Gateway Server Offline event only fire when I manually take a server offline?

No. Beyond a manual offline in Edge Admin, OpenResty Edge actively probes each gateway server with health checks, so the Gateway Server Offline event fires when that probing detects the server down, when the server itself hits an anomaly, or when you mark it offline manually. A webhook subscribed to it therefore catches every outage, not only planned ones.

How do I confirm a webhook was actually delivered?

Open the Webhooks page in Edge Admin and choose the Detail button for your webhook to view its execution history. Each entry there records a triggered event that was sent to your custom API successfully, so you can verify delivery without instrumenting your own endpoint.

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.