How to install the Send Event to Endpoint solution through Azion Marketplace
Overview
Azion Send Event to Endpoint is a serverless solution available at Azion Marketplace. This solution enables you to stream request data to an HTTP endpoint, taking the request data and transmitting it to a user-defined endpoint via Javascript fetch API.
The solution also permits you to specify what kind of data you wish to capture by editing a JSON
file.
After sending the collected data, the solution allows the request to proceed through the Rules Engine.
1 . Getting the solution
To use the Send Event to Endpoint solution, you have to:
- Log in to your Real-Time Manager (RTM) account.
- If you don’t have an account, you can create one by visiting the sign-up page.
- On the upper-left corner of the RTM homepage, select Products menu, identified by the three horizontal lines, > Marketplace.
- Select the search box and type “Endpoint” or browse through the cards to find the Send Event to Endpoint solution.
- Once you’ve found the Send Event to Endpoint card, select it to go to the solution’s page.
- On the solution’s page, look for the Subscribe for section on the bottom-right corner.
- Click the Get It Now button.
You’ll see a message indicating that your solution was successfully installed and is ready to use.
2. Using the solution
2.1 Setting up the Edge Firewall Rule
To instantiate the Send Event to Endpoint solution, follow these steps:
- Under Products menu, select Edge Firewall in the SECURE section.
- Click the Add Rule Set button.
- Give an easy to remember name to your new rule.
- Select the domains you want to protect with the function.
- Turn the Edge Functions switch on.
- Click the Save button.
Done. Now you have instantiated the rule for your function.
2.2 Setting up the solution
To instantiate the Send Event to Endpoint solution, while still on the Edge Firewall page, select the Functions tab and follow these steps:
- Click the Add Function button.
- Give an easy to remember name to your instance.
- On the dropdown menu, select the Send Event to Endpoint function.
After you select the solution, a Code form with the solution’s source-code will be loaded. This is just for study and can’t be modified. In the same form you have another tab: the Args tab. On the Args tab, you’ll pass the parameters to configure your solution.
The JSON
Args form for this solution will look like this:
{
"metadata": ["remote_addr"],
"headers": ["x-hello"],
"body": ["message", "user.id"],
"connection_args": {
"endpoint": "http://example_api:3000/test",
"headers": {
"Authorization": "FakeAuth",
"X-Provider": "Azion Cells"
}
}
}
Where:
Field | Is Required | Data Type | Notes |
---|---|---|---|
metadata |
No | Null or Array | Defines which metadata fields will be streamed. When null (or not set), all metadata fields will be streamed.If you don’t want to stream any metadata, you must set an empty array [ ] as the value of this field. |
headers |
No | Null or Array | Defines which request headers will be streamed. When null (or not set), all request headers will be streamed.If you don’t want to stream any header, you must set an empty array [ ] as the value of this field. |
body |
No | Null or Array | Defines which request body fields will be streamed. When null (or not set), all request body fields will be streamed.If you don’t want to stream any body field, you must set an empty array [ ] as the value of this field.To filter multi-level fields, use the dot notation. For example, if you use the string ‘user.name’ here, the function will seek for the field ‘name’ within the object ‘user’ in the request body. |
connection_args |
Yes | Object | Defines the data that will be used to stream the request data. The URL to which the data will be posted is defined by the endpoint. The headers specify which headers will be included in the fetch request. An additional ‘Content-Type: application/json’ header will be used. |
This solution will return a response with the data streamed in a JSON
file that will be look like this:
{
"body": {
"field_a": <data>,
...
},
"geoip_asn": <data>,
"geoip_city": <data>,
"geoip_city_continent_code": <data>,
"geoip_city_country_code": <data>,
"geoip_city_country_name": <data>,
"geoip_continent_code": <data>,
"geoip_country_code": <data>,
"geoip_country_name": <data>,
"geoip_region": <data>,
"geoip_region_name": <data>,
"headers": {
"x-header-a": <data>,
...
},
"remote_addr": <data>,
"remote_port": <data>,
"remote_user": <data>,
"request_id": <data>,
"request_url": <data>,
"server_protocol": <data>,
"ssl_cipher": <data>,
"ssl_protocol": <data>
}
Notice how the request_id
, request_url
, and metadata fields will be delivered in the root of the JSON
file, whereas the body fields and request headers will be sent in objects.
Important: you can also use a “catch-all” JSON
Args file, like this:
{
"connection_args": {
"endpoint": "http://example_api:3000/test",
}
}
3. Setting up Rules Engine
To finish, you have to set up the Rules Engine to configure the behavior and the criteria to run the solution.
Still in the Edge Firewall page, select the Rules Engine tab and follow these steps:
- Click the New Rule button.
- Give an easy to remember name to the rule.
- Select a criteria to run and catch the domain you want to run the solution on. For example:
if Hostname is equal xxxxxxxxxxxx.map.azionedge.net
. - Below, select a behavior to the criteria. In this case, it’ll be Run Function. Then, select the adequate Send Event to Endpoint function according to the name you gave it in the instantiating step.
Done. Now the Send Event to Endpoint solution is running for every request made to the domain you indicated.
Didn’t find what you were looking for? Open a support ticket.