Using custom data to enrich events

You can use custom data in event enrichment in a similar way to normal data.

Before you begin

Ensure that you are familiar with how to do event enrichment with normal data. If you want to use a new field in the ObjectServer alerts.status table to store the enriched data, you must create the field in the ObjectServer first before following the steps below.

About this task

The name of an interface is available in the NCIM topology database interface table. This field can be accessed using NCIM cache, and is held in the ncimCache.entityData table.

The following steps explain how to configure this extra event enrichment.

Procedure

  1. Edit the Event Gateway schema file, $NCHOME/etc/precision/EventGatewaySchema.cfg, to allow the Event Gateway to update the new field. Remember to add a comma at the end of the line containing the NmosSerial field, before the line containing the new InterfaceName field.
    For example, to configure the Event Gateway to update a new field customer, add the text in bold to the outgoing event filter.
    insert into config.ncp2nco
    (
        FieldFilter
    )
    values
    (
        [
            "NmosCauseType",
            "NmosDomainName",
            "NmosEntityId",
            "NmosManagedStatus",
            "NmosObjInst",
            "NmosSerial",
            "Customer"
        ]
    );
    Note: Fields that are added to the outgoing event filter are automatically added to the incoming field filter, config.nco2ncp, thus ensuring that the current value of the field is retrieved. This allows the StandardEventEnrichment stitcher to check the value of the InterfaceName field before updating it. This technique ensures that the Event Gateway does not keep updating the same value.
  2. Edit the Event Gateway stitchers to retrieve the customer information from the topology database and to populate the Customer field.
    One way to do this is by adding code to the StandardEventEnrichment stitcher. The code is different depending whether you added custom data as name-value pairs to the entityDetails table or created a custom database table. Adding this code to the stitcher ensures that this procedure is performed for all topology events that are matched to an entity. Add this code to the stitcher immediately before the final line, the call to GwEnrichEvent( enrichedFields ) and after determining the entityType value.

    The following example code takes the value of customerId from the entityDetails table in the ncimCache files. Use this method if you added custom data without creating new NCIM database tables.

    if ( entityType == 1 )
    {
         text customerName = @entity.entityDetails.customerId;
     
        if ( customerName <> eval(text, '&Customer') )
        {
              @enrichedFields.Customer = customerName;
        }
    }
    Table 1. Lines of code relevant to the interface name example
    Line numbers Description
    1 This event enrichment is only relevant for chassis events. Check that this event relates to a chassis by ensuring that the entityType value is 1, and if so, continue processing.
    3 Retrieve the customer data from the entityDetails table.
    Note: Fields within the NCIM cache are usually in all uppercase, for example, @mainNode.chassis.SYSLOCATION. In this example, customerName is in mixed case because it is in the entityDetails table.
    5 - 8 Only populate the Customer field if the value is not already present in the in-scope event.

    The following example code takes the value of customerName from the customer table in the ncimCache files. Use this method if you added custom data to a new NCIM database table.

    if ( entityType == 1 )
    {
         text customerName = @entity.customer.CUSTOMERNAME;
     
        if ( customerName <> eval(text, '&CustomerName) )
        {
              @enrichedFields.CustomerName = customerName;
        }
    }