How to debug rules created with Rules Engine
Debug Rules allows you to check whether rules or rule sets created using the Rules Engine module for Edge Application and Edge Firewall have been successfully executed in your application.
You can debug rules using the GraphQL API, Azion Data Stream, and Azion Real-Time Events.
Learn more about Rules EngineEnabling Debug Rules
To debug your rules or rule sets, you must first activate the Debug Rules feature on Azion’s interface.
To enable Debug Rules for Edge Application:
- Access Console.
- Go to Products menu > Edge Application.
- Select an existing edge application to activate debug.
- On the Main Settings tab, enable the Debug Rules option.
- Click the Save button.
- Access Real-Time Manager (RTM).
- Go to Products menu > Edge Application.
- Select an existing edge application to activate debug.
- On the Main Settings tab, enable the Debug Rules option.
- Click the Save button.
To enable Debug Rules for Edge Firewall:
- Access Console.
- Go to Products menu > Edge Firewall.
- Select the edge firewall you want to configure.
- On the Main Settings tab, enable the Debug Rules option.
- Click the Save button.
- Access Real-Time Manager (RTM).
- Go to Products menu > Edge Firewall.
- Select the edge firewall you want to configure.
- On the Main Settings tab, enable the Debug Rules option.
- Click the Save button.
Debugging rules with the GraphQL API
To query the available rules data in the GraphQL API, follow the steps described on How to query GraphQL requests on Postman using the https://api.azionapi.net/events/graphql
URL.
Then, on Postman’s GraphQL request code box, add the following HTTP Query, modifying the tsRange
to fit the time interval you want:
The example above shows a query for rule data using the HTTP Events dataset. The limit field filters the last 10 entries within the tsRange field. The presented data is ordered through the ts (timestamp) field.
The query above should return:
- ts: the time range for when each request was initiated.
- remoteAddress: the IP of the client that made the request to the application.
- requestUri: the type of HTTP request and URI.
- stacktrace: executed rules and rule sets.
Send your request. You’ll receive a response similar to this:
In this example, the GraphQL API has returned all active request and response phase rules created for Edge Application, as well as an active Edge Firewall rule set.
For more information on the GraphQL API, visit the datasets documentation page.
Debugging rules using Data Stream
To debug rules via Data Stream, follow these steps:
-
Access Console.
-
Select Products menu > Data Stream.
-
Click + Stream.
-
Choose a name for your stream.
-
On the Source dropdown menu, select Edge Applications.
-
On the Template dropdown menu, select Custom Template.
-
On the Data Set code box, add the following variables:
{ "time": "$time", "traceback": "$traceback" }
-
On Domains, select between Filter Domains or All Current and Future Domains. See more about each option on How to associate domains on Data Stream.
-
On the Destination section, select an Connector on the dropdown menu.
- You’ll see different fields depending on the endpoint type you choose. Find more information on each of them on the Setting an endpoint page.
- Make sure the Status switch is active.
- Click the Save button.
To make sure your logs are being sent to your endpoint through the configured stream, you can use Real-Time Events to query detailed analysis.
To see all your created stream, go to the Data Stream page on Azion Console and select one from the list. Feel free to create multiple ones.
-
Access Real-Time Manager (RTM).
-
Select Products menu > Data Stream.
-
Click Add Stream.
-
Choose a name for your stream.
-
On the Data Source dropdown menu, select Edge Applications.
-
On the Template dropdown menu, select Custom Template.
-
On the Data Set code box, add the following variables:
{ "time": "$time", "traceback": "$traceback" }
-
On Options, select between Filter Domains or All Domains. See more about each option on How to associate domains on Data Stream.
-
On the Destination section, select an Endpoint Type on the dropdown menu.
- You’ll see different fields depending on the endpoint type you choose. Find more information on each of them on the Setting an endpoint page.
- Make sure the Active switch is turned on.
- Click the Save button.
To make sure your logs are being sent to your endpoint through the configured stream, you can use Real-Time Events to query detailed analysis.
To see all your created stream, go to the Data Stream page on Azion Console and select one from the list. Feel free to create multiple ones.
Variables definition
Variable | Definition |
---|---|
$time | Request date and time. Example: Oct. 31st, 2022 - 19:30:41 |
$traceback | Provides the names of the rules created using Rules Engine for Edge Application and Edge Firewall that are run by the request. |
Debugging rules using Real-Time Events
To access Real-Time Events, follow these steps:
- Access Console.
- On the upper-left corner, select Products menu > Real-Time Events.
- Select the HTTP Requests tab.
- Modify the desired time range and add filters if needed.
- Click the Search button.
- Select the log body you want to inspect.
- Look for the traceback field.
The traceback field should contain the type of rule executed and the behavior triggered within the selected time range. For instance:
{\"edge_application_response\":[\"Add Azion Cookie\"],\"edge_firewall\":[\"Set WAF\",\"Rate-Limit Root\"],\"edge_application_request\":[\"Default Rule\",\"Test Send Cert to Origin 1\",\"Test Send Cert to Origin 2\"]}
In this example, the traceback field contains all active request and response phase rules created for Edge Application, as well as an active Edge Firewall rule set.
- Access Real-Time Manager (RTM).
- On the upper-left corner, select Products menu > Real-Time Events.
- On Data Source, select Edge Applications.
- Modify the desired time range and add filters if needed.
- Click the Search button.
- Select the log body you want to inspect.
- Look for the traceback field.
The traceback field should contain the type of rule executed and the behavior triggered within the selected time range. For instance:
{\"edge_application_response\":[\"Add Azion Cookie\"],\"edge_firewall\":[\"Set WAF\",\"Rate-Limit Root\"],\"edge_application_request\":[\"Default Rule\",\"Test Send Cert to Origin 1\",\"Test Send Cert to Origin 2\"]}
In this example, the traceback field contains all active request and response phase rules created for Edge Application, as well as an active Edge Firewall rule set.