How to install the Send Event to Endpoint integration through Azion Marketplace
Azion Send Event to Endpoint is a serverless integration available at Azion Marketplace. This integration 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 integration also permits you to specify what kind of data you wish to capture by editing a JSON
file.
After sending the collected data, the integration allows the request to proceed through the Rules Engine.
Getting the integration
To use the Send Event to Endpoint integration, you have to:
- Access Azion Console > Marketplace.
- On the Marketplace homepage, select Send Event to Endpoint card.
- Once the integration’s page opens, click the Install button.
You’ll see a message indicating that your integration was successfully installed.
- Access Real-Time Manager (RTM) > Marketplace.
- On the Marketplace homepage, select Send Event to Endpoint card.
- Once the integration’s page opens, click the Get It Now button, at the bottom-right corner of the page.
You’ll see a message indicating that your integration was successfully installed.
Configuring the integration
Setting up an edge firewall
To instantiate the Send Event to Endpoint integration, follow these steps:
- Under Products menu, select Edge Firewall in the SECURE section.
- Click the + Edge Firewall button.
- Give an easy to remember name to your edge firewall.
- Turn the Edge Functions switch on.
- Click the Save button.
Done. Now you have instantiated the edge firewall for your function.
- Under Products menu, select Edge Firewall in the SECURE section.
- Click the Add Rule Set button.
- Give an easy to remember name to your edge firewall.
- 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.
Setting up the integration
To instantiate the Send Event to Endpoint integration, while still on the Edge Firewall page:
- Select the Functions Instances tab.
- Click the + Function Instance button.
- Give an easy to remember name to your instance.
- On the dropdown menu, select the Send Event to Endpoint function.
- This action will load the Arguments tab.
The Arguments tab will load a JSON
file that looks like this:
Where:
Field | 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. |
s3_connection_args | No | Object | Defines the arguments used to connect to the S3 bucket. |
s3_connection_args.full_host | Only when using s3_connection_args | String | Defines the full host of the S3 bucket. |
s3_connection_args.region | Only when using s3_connection_args | String | Defines the region of the S3 bucket. |
s3_connection_args.access_key | Only when using s3_connection_args | String | Defines the access key to be used in the connection to the S3 bucket. |
s3_connection_args.secret_key | Only when using s3_connection_args | String | Defines the secret key to be used in the connection to the S3 bucket. |
s3_connection_args.file_path | No | String | Defines the path where the file created by the function must be stored. Default value: / |
s3_connection_args.use_date_prefix | No | String | When enabled, it’ll include a sub-folder with the current date (in format YYYY-MM-DD) to the file path. Default value: true |
This integration will return a response with the data streamed in a JSON
file that will look like this:
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:
S3 output files
For each new function run, a new file will be produced in the given S3 bucket. The file will be named after the request ID that initiated the function.
Example: if the connection_args.file_path
parameter is set to /my-data/
and the function is performed on May 9th, 2023, with the request ID abcd-1234
, the resultant file will be saved at /my-data/2023-05-09/abcd-1234.json
. If the connection_args.use_date_prefix
parameter is set to false
, the resultant file will be saved as /my-data/abcd-1234.json
.
If there are no http_connection_args
or s3_connection_args
supplied in the JSON Args, the function doesn’t have any valid connection arguments to utilize. Then, the request will be terminated, and a JSON
error message will be sent to indicate the cause of the issue.
If the function is unable to connect to the HTTP endpoint or the S3 provider, the user request will be ignored. Regardless, an error log will be created, which the client may access via Data Stream.
For example, if an invalid access key is used, the following notice will be displayed:
At last, if you supply the correct connection options for both the HTTP endpoint and the S3 bucket, the function will deliver event data to both sources at the same time.
- 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 integration, a Code form with the integration’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 integration.
The JSON
Args form for this integration will look like this:
Where:
Field | 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. |
s3_connection_args | No | Object | Defines the arguments used to connect to the S3 bucket. |
s3_connection_args.endpoint | Only when using s3_connection_args | String | Defines the endpoint of the S3 provider. |
s3_connection_args.bucket | Only when using s3_connection_args | String | Defines the name of the destination bucket. |
s3_connection_args.region | Only when using s3_connection_args | String | Defines the region of the S3 bucket. |
s3_connection_args.access_key | Only when using s3_connection_args | String | Defines the access key to be used in the connection to the S3 bucket. |
s3_connection_args.secret_key | Only when using s3_connection_args | String | Defines the secret key to be used in the connection to the S3 bucket. |
s3_connection_args.file_path | No | String | Defines the path where the file created by the function must be stored. Default value: / |
s3_connection_args.use_date_prefix | No | String | When enabled, it’ll include a sub-folder with the current date (in format YYYY-MM-DD) to the file path. Default value: true |
This integration will return a response with the data streamed in a JSON
file that will look like this:
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:
S3 output files
For each new function run, a new file will be produced in the given S3 bucket. The file will be named after the request ID that initiated the function.
Example: if the connection_args.file_path
parameter is set to /my-data/
and the function is performed on May 9th, 2023, with the request ID abcd-1234
, the resultant file will be saved at /my-data/2023-05-09/abcd-1234.json
. If the connection_args.use_date_prefix
parameter is set to false
, the resultant file will be saved as /my-data/abcd-1234.json
.
If there are no http_connection_args
or s3_connection_args
supplied in the JSON Args, the function doesn’t have any valid connection arguments to utilize. Then, the request will be terminated, and a JSON
error message will be sent to indicate the cause of the issue.
If the function is unable to connect to the HTTP endpoint or the S3 provider, the user request will be ignored. Regardless, an error log will be created, which the client may access via Data Stream.
For example, if an invalid access key is used, the following notice will be displayed:
At last, if you supply the correct connection options for both the HTTP endpoint and the S3 bucket, the function will deliver event data to both sources at the same time.
Setting up Rules Engine
To finish, you have to set up the Rules Engine to configure the behavior and the criteria to run the integration.
Still in the Edge Firewall page:
- Select the Rules Engine tab.
- Click the + Rule Engine button.
- Give a name to the rule.
- Select a criteria to run and catch the domains that you want to run the integration on.
- Example: if
Host
matchesyourdomain.com
.
- Below, select a behavior to the criteria. In this case, it’ll be Run Function.
- Select the adequate function according to the name you gave it during the instantiation step.
- Click the Save button.
On the Console, you must now configure your domain so your edge firewall protects it.
- On the Products menu, select Domains.
- Click on the domain you want to protect with your Send Event to Endpoint function.
- In the Settings section, click on the
Edge Firewall
selector and choose the edge firewall you created. - Click the Save button.
Done. Now the Send Event to Endpoint integration is running for every request made to the domain you indicated.
- Select the Rules Engine tab.
- 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 integration 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.
- Click the Save button.
Done. Now the Send Event to Endpoint integration is running for every request made to the domain you indicated.