JS Code Forwarding
The JS Code forwarder is a robust batch processing tool designed to efficiently handle and forward batches of events.
Last updated
The JS Code forwarder is a robust batch processing tool designed to efficiently handle and forward batches of events.
Last updated
The JS Code forwarder is a robust batch processing tool designed to efficiently handle and forward batches of events. It supports forwarding arrays of event objects to a specified endpoint, and includes built-in functions for recording metrics, making HTTP requests, and logging.
This forwarder, equipped with JavaScript execution capabilities, revolutionises log shipping by allowing users to dynamically process transported logs in real-time with custom JavaScript functions.
For example, users can define JavaScript functions to scan incoming logs, identify specific patterns or anomalies, and automatically trigger actions, like filing tickets in response to detected issues. This seamless integration of JavaScript-based log processing directly within the forwarder streamlines the log management workflow, enabling organisations to swiftly and efficiently respond to critical events or conditions detected within their log data, thereby enhancing operational efficiency and proactive incident management.
Batch Forwarding
The JS Code forwarder operates as a batch forwarder, capable of receiving and processing one or more events in a single batch. It handles the array of event objects and forwards them to the designated endpoint.
Metrics Recording
A built-in metric function logs essential forwarder metrics, such as successful data forwarding instances and the total bytes of data forwarded. This aids in monitoring and optimizing the forwarder’s performance.
The JS Code forwarder processes batched events instead of individual events, passed to the forwarder as an array.
Event Object Format
Each event within the batched array follows a specific format:
Copy
In the jscode forwarder code environment, the following built-in variables and functions are available:
Functions
fetchSync(url, cfg)
: Makes a synchronous HTTP request to the specified endpoint.
Arguments:
url
: The URL of the target endpoint.
cfg
: Configuration object containing the method, headers, and body of the request.
Returns: The response from the target endpoint.
console.log(message)
: Logs messages to the console.
Arguments: message
(string) - The message to log.
Variables
Events
: An array containing the events to be forwarded to the target endpoint.
The following example demonstrates how to implement a jscode forwarder:
Copy
This example shows how to configure and use the fetchSync
function to forward the batched events to a specified endpoint. The cfg
object includes the HTTP method, headers, and the body containing the events to be forwarded.
The JS Code forwarder is a powerful tool for batch forwarding of events, equipped with built-in functions for HTTP requests and console logging. By following this documentation, users can effectively implement and utilize the jscode forwarder in their systems.