Create event field mappings with advanced mapping script
Create event field mappings with advanced mapping scripts to transform raw event data into structured, meaningful information. This method goes beyond basic configurations, aligns fields with business context, and improves event correlation. By reducing alert noise and enhancing visibility, it helps teams respond faster and manage incidents more effectively.
Before you begin
Role required: evt_mgmt_admin
Procedure
Example
The use case for this script is to automatically enrich incoming events with classification details before they are processed further. For example, by adding u_alert_classification = "Network" into the event’s metadata, the system can tag and group network-related alerts more effectively. This helps streamline event correlation, reduce noise, and improve routing so incidents are categorized and resolved faster.
This script checks the event’s additional_info field, ensures it contains valid JSON, and then updates it by adding a new property called u_alert_classification with the value “Network.” If the JSON is invalid, it logs an error and stops the binding. Otherwise, it saves the updated data back to the event record and allows the binding to proceed.
try {
var addInfo = eventGr.getValue('additional_info');
if (!addInfo) {
addInfo = "{}";
}
var addInfoJson = {};
// Parse JSON
try {
addInfoJson = JSON.parse(addInfo);
} catch (parseError) {
gs.error("Error parsing additional_info: " + parseError);
return false;
}
addInfoJson.u_alert_classification = "Network";
var updatedAddInfo = JSON.stringify(addInfoJson);
eventGr.setValue('additional_info', updatedAddInfo);
return true;
} catch (e) {
gs.error("The script type mapping rule '" + fieldMappingRuleName + "' ran with the error: \n" + e);
}