Extracting Alarm Data Points and Thresholds to Custom Fields via LUA
search cancel

Extracting Alarm Data Points and Thresholds to Custom Fields via LUA

book

Article ID: 441788

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM)

Issue/Introduction

To programmatically extract numerical data points (current values) and thresholds from standard alarm messages and populate them into the custom_1 and custom_2 fields of the alarm XML for enhanced reporting and integration.

Environment

  • Product: DX Unified Infrastructure Management (Nimsoft / UIM)
  • Probe: nas (Alarm Server)
  • Component: LUA Scripting / Pre-processing Rules

Resolution

Step 1: Create the LUA Script

  1. Open the nas probe configuration in Infrastructure Manager or Admin Console.
  2. Navigate to the Scripts tab (or Script Editor).

Create a new script named enrich_custom_fields and paste the following code:

if event ~= nil and event.message ~= nil then
    -- 1. Extract the current value (the number before the first %)
    local val = string.match(event.message, "is now%s+([%d%.]+)%%")
    
    -- 2. Extract the limit threshold (the number inside the parentheses before %)
    local lim = string.match(event.message, "threshold%s+%(([%d%.]+)%%%)")

    -- 3. If the pattern changes slightly, use a generic backup pattern to capture two numbers
    if not val or not lim then
        val, lim = string.match(event.message, "is now%s+([%d%.]+).-[%(%s]([%d%.]+)%%")
    end

    -- 4. If values were found, assign them to the custom fields
    if val then
        event.custom_1 = val
    end
    if lim then
        event.custom_2 = lim
    end
end

-- Return the updated event back to nas
return event


Step 2: Configure the Pre-processing Rule

  1. In the nas probe configuration, navigate to the Pre-processing Rules tab.
  2. Create a new rule (e.g., populate_custom_data).
  3. Set the Type to custom.
  4. Select the script enrich_custom_fields from the Script dropdown.
  5. Set the Filter criteria to match the specific alarms you wish to process (e.g., set Probe to cdm or use a Message Filter like /*is now*threshold*/).
  6. Click OK and restart the nas probe to apply changes.


Verification

  1. Trigger a test alarm that matches your filter.
  2. View the alarm in the Alarm Console.
  3. Check the Custom 1 and Custom 2 columns; they should now display the raw numerical values extracted from the message.

Example output: