- Checks if the response status code is not in the 200 range
- Logs the unsuccessful request with a custom message and metadata
log Traffic Policy action docs for more information.Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Learn how to configure event logging in Traffic Policy to export logs to external services like Datadog for monitoring and troubleshooting.
on_http_request:
- actions:
- type: custom-response
config:
status_code: 503
body: "<html><body><h1>Service Unavailable</h1><p>Our servers are currently
down for maintenance. Please check back later.</p></body></html>"
headers:
content-type: text/html
on_http_response:
- name: Log unsuccessful requests
expressions:
- res.status_code < '200' && res.status_code >= '300'
actions:
- type: log
config:
metadata:
message: Unsuccessful request
edge_id: "<YOUR-NGROK-DOMAIN>"
success: false
{
"on_http_request": [
{
"actions": [
{
"type": "custom-response",
"config": {
"status_code": 503,
"body": "<html><body><h1>Service Unavailable</h1><p>Our servers are currently down for maintenance. Please check back later.</p></body></html>",
"headers": {
"content-type": "text/html"
}
}
}
]
}
],
"on_http_response": [
{
"name": "Log unsuccessful requests",
"expressions": [
"res.status_code < '200' && res.status_code >= '300'"
],
"actions": [
{
"type": "log",
"config": {
"metadata": {
"message": "Unsuccessful request",
"edge_id": "<YOUR-NGROK-DOMAIN>",
"success": false
}
}
}
]
}
]
}
log Traffic Policy action docs for more information.Was this page helpful?