Adding Custom Fields to the Event Database

Using the Unified Assurance UI, you can add new custom fields to the event database, clone existing fields and then change their settings, or delete custom fields you have added. You can also make changes to the index type of some of the default fields. You cannot delete the default fields.

The event database is a MySQL database internal to Unified Assurance only. It is not intended to integrate directly with external tools or clients. Do not attempt to make changes in the event database through the command line, third party tools, or other methods than those described here. You can only use the Unified Assurance UI, application rules, and REST API to access the event database and make changes.

At a high level, making changes involves the following:

  1. Stopping services.

  2. Preparing changes in the UI.

  3. Applying the changes to the database.

  4. Optionally, updating rules files.

  5. Restarting services, recreating indices.

  6. Verifying functionality.

See Adding Custom Fields for details.

When you restart applications after adding custom fields to the database, the applications use read in the database fields and create a default insert statement. You can customize this statement if you need different functionality or custom deduplication settings. See Custom Deduplication for details.

Note:

The examples in this document are for reference only.

Adding Custom Fields

This section describes the tasks involved in adding custom fields. You perform the tasks using the Unified Assurance user interface (UI) and the command line.

Dependencies for Adding Custom Fields

Best Practices for Adding Custom Fields

When adding custom fields and making other changes, keep the following best practices in mind:

Task 1: Stop Event Services and Microservices

  1. In a browser, sign in to the Unified Assurance UI.

  2. From the Configuration menu, select Broker Control, then Services.

  3. Select any of the following services that are running and click Stop:

    • Any event-based applications, such as the Event Syslog Aggregator.

    • Any thresholding-based applications, such as the Metric Standard Thresholding Engine.

    • MySQL Replication Data Importer services

  4. From the Configuration menu, select Microservices, then Installed.

  5. For any event-based microservices, such as Event Sink, click Delete.

Task 2: Use the UI to Prepare Changes to the Table

  1. In a browser, sign in to the Unified Assurance UI.

  2. From the Configuration menu, select Events, then Custom Event Fields.

  3. Add a new field, make changes to an existing field, delete a custom field, and make additional changes as needed.

Task 3: Apply the Changes to the Database

  1. Log in to the command line of the database server.

  2. Change to the assure1 user.

  3. Go to the following directory:

    cd $A1BASEDIR/bin/
    
  4. Optionally, run the ApplyEventSchema application with the --Dry-Run option for a preview of changes:

    1. Log the queries that will be run to change the database:

      ./ApplyEventSchema --Dry-Run
      
    2. Review the queries in the log file:

      lnav logs/ApplyEventSchema.log
      
  5. Run ApplyEventSchema:

    • For non-sharded environments, run the following command:

      ./ApplyEventSchema
      
    • For environments with multiple event shards, do one of the following:

    • On any of the database servers, run ApplyEventSchema with the --EventShard 0 flag:

      ./ApplyEventSchema --EventShard 0
      
    • On the primary instance of the database server, run ApplyEventSchema with the -EventShard flag, replacing <N> with the correct Event Shard ID:

      ./ApplyEventSchema --EventShard <N>
      

Task 4: Start the MySQL Replication Data Importer

  1. In a browser, sign in to the Unified Assurance UI.

  2. From the Configuration menu, select Broker Control, then Services.

  3. Find and select any MySQL Replication Data Importer services.

  4. Click Start.

Task 5: (Optional) Update Rules Files

  1. In a browser, sign in to the Unified Assurance UI.

  2. From the Configuration menu, Rules.

  3. Update the relevant rules files for applications to insert or update data in the real-time database. See Custom Deduplication for examples of updating insert statements and deduplication settings in rules files.

Task 6: Start the Event Services and Microservices

  1. In a browser, sign in to the Unified Assurance UI.

  2. From the Configuration menu, select Broker Control, then Services.

  3. Select any event-based services that you stopped in Task 1.

  4. Click Start.

  5. From the Configuration menu, select Microservices, then Installed.

  6. Repeat the following for any event-based microservices that you stopped in Task 1:

    1. Select the microservice.

    2. Click Deploy.

    3. Select a cluster and namespace, edit any default configurations, optionally update the release name, and click Start.

Task 7: Recreate the Kibana Index

Note:

Perform this task after data has been inserted into the newly added fields. Data can be inserted into the fields using rules, by manually updating an event through the UI, or other steps as well.

  1. In a browser, sign in to the Unified Assurance UI.

  2. From the Analytics menu, select Events, then Administration, then Management.

  3. In the menu, under Kibana, select Index Patterns.

  4. Select eventanalytics-*.

  5. Click the Refresh button in the upper right.

Task 8: Verifying Functionality

To verify the new field (or fields) are available for use, start or reload an event-based application. Build Generic Insert and Build Generic FieldSet logging should show the new fields as being available for use.

For example:

[DATE TIME] [BINARY NAME]([PROCESS ID])<-> [INFO] Build Generic Insert as:

        INSERT INTO Events (EventKey,EventCategory,EventType,Ack,Action,Actor,Count,Customer,Department,Details,DeviceType,Duration,EscalationFlag,ExpireTime,FirstReported,GeoPath,GeoLocation,IPAddress,LastChanged,LastReported,Location,Method,Node,OrigSeverity,OwnerName,RootCauseFlag,RootCauseID,Score,Service,ServiceImpact,Severity,SubDeviceType,SubMethod,SubNode,Summary,TicketFlag,TicketID,ZoneID,RootCauseKey,NewField1)
             VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,ST_GeomFromGeoJson(?,1,4326),ST_GeomFromGeoJson(?,1,4326),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
                 ON DUPLICATE KEY
             UPDATE Count         = Count + 1,
                    Duration      = VALUES(LastReported) - FirstReported,
                    EventCategory = VALUES(EventCategory),
                    LastChanged   = VALUES(LastChanged),
                    LastReported  = VALUES(LastReported),
                    Severity      = VALUES(Severity),
                    Summary       = VALUES(Summary)

[DATE TIME] [BINARY NAME]([PROCESS ID])<-> [INFO] Build Generic FieldSet as:
EventKey,EventCategory,EventType,Ack,Action,Actor,Count,Customer,Department,Details,DeviceType,Duration,EscalationFlag,ExpireTime,FirstReported,GeoPath,GeoLocation,IPAddress,LastChanged,LastReported,Location,Method,Node,OrigSeverity,OwnerName,RootCauseFlag,RootCauseID,Score,Service,ServiceImpact,Severity,SubDeviceType,SubMethod,SubNode,Summary,TicketFlag,TicketID,ZoneID,RootCauseKey,NewField1

Custom Deduplication

This section details the tasks involved in implementing custom deduplication so that Unified Assurance performs a custom action when a duplicate event is received. While these changes are relatively easy to make, they can cause issues if done incorrectly.

Best Practices for Custom Deduplication

Task 1: Adding Custom Deduplication Files

To implement custom deduplication:

  1. Create a InsertSQLFile.sql file with the following content:

    INSERT INTO Events (EventKey,EventCategory,EventType,Ack,Action,Actor,Count,Customer,Department,Details,DeviceType,Duration,EscalationFlag,ExpireTime,FirstReported,GeoPath,GeoLocation,IPAddress,LastChanged,LastReported,Location,Method,Node,OrigSeverity,OwnerName,RootCauseFlag,RootCauseID,Score,Service,ServiceImpact,Severity,SubDeviceType,SubMethod,SubNode,Summary,TicketFlag,TicketID,ZoneID,RootCauseKey,<NewField1>)
    VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,ST_GeomFromGeoJson(?,1,4326),ST_GeomFromGeoJson(?,1,4326),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,<?>)
    ON DUPLICATE KEY
    UPDATE Count         = Count + 1,
    Duration      = VALUES(LastReported) - FirstReported,
    EventCategory = VALUES(EventCategory),
    LastChanged   = VALUES(LastChanged),
    LastReported  = VALUES(LastReported),
    Severity      = VALUES(Severity),
    Summary       = VALUES(Summary),
    <NewField1> = VALUES(<NewField1>)
    

    This statement controls which fields are inserted when an event is initially received and which fields are updated when a duplicate event is received.

  2. Replace <NewField1> and <?> and customize the statement as follows:

    • In the INSERT INTO list of columns, replace <NewField1> with the new field name and add additional comma-separated fields to the list.

    • In the VALUES list, replace <?> with a single question mark (?), and add additional comma-separated question marks for each additional field that is being added to the list.

    • In the ON DUPLICATE KEY list, replace <NewField1> with the new field name. You can also add other MySQL functionality here.

  3. Save the file.

  4. Create a FieldSetFile.sql file with the following content:

    EventKey, EventCategory, EventType, Ack, Action, Actor, Count, Customer, Department, Details, DeviceType, Duration, EscalationFlag, ExpireTime, FirstReported, GeoPath, GeoLocation, IPAddress, LastChanged, LastReported, Location, Method, Node, OrigSeverity, OwnerName, RootCauseFlag, RootCauseID, Score, Service, ServiceImpact, Severity, SubDeviceType, SubMethod, SubNode, Summary, TicketFlag, TicketID, ZoneID, RootCauseKey, <NewField1>
    

    This information determines what fields are replacing the SQL placeholders (question marks) in the statement in InsertSQLFile.sql.

  5. Replace <NewField1> with the new field name, and add each additional field to the list before saving the file.

  6. Save the file.

  7. Add both files to the common folder of the rules repository:

    1. In a browser, sign in to the Unified Assurance UI.

    2. From the Configuration menu, select Rules.

    3. Expand the following folder path:

      Core Rules (rules)/Default read-write branch (default)/collection/event

    4. Select the common folder.

    5. Click Upload.

    6. In FileName, enter InsertSQLFile, or your custom file name.

    7. Click Browse and select your local InsertSQLFile.sql file.

    8. Click Submit.

    9. Click Upload.

    10. In FileName, enter FieldSetFile, or your custom file name.

    11. Click Browse and select your custom FieldSetFile.sql file.

    12. Click Submit.

Task 2: Updating Application Configuration Settings

Repeat this procedure for any application that should use the custom files:

  1. In a browser, log in to the Unified Assurance UI.

  2. From the Configuration menu, select Broker Control, then either Services or Jobs.

  3. Select the application.

  4. In the Configuration section:

    • Set InsertSQLFile to collection/event/common/InsertSQLFile.sql, or the custom location and name of your InsertSQLFile.

    • Set FieldSetFile to collection/event/common/FieldSetFile.sql or the custom location and name of your FieldSetFile.

    If these fields are not in the list, add them.

  5. Restart the application.

Task 3: Verifying Custom Deduplication Functionality

To verify that the new fields are available for deduplication, start or reload an application. Build Generic Insert and Build Generic FieldSet logging should show the new fields.

For example:

[DATE TIME] [BINARY NAME]([PROCESS ID])<-> [INFO] Build Generic Insert as:
INSERT INTO Events (EventKey,EventCategory,EventType,Ack,Action,Actor,Count,Customer,Department,Details,DeviceType,Duration,EscalationFlag,ExpireTime,FirstReported,GeoPath,GeoLocation,IPAddress,LastChanged,LastReported,Location,Method,Node,OrigSeverity,OwnerName,RootCauseFlag,RootCauseID,Score,Service,ServiceImpact,Severity,SubDeviceType,SubMethod,SubNode,Summary,TicketFlag,TicketID,ZoneID,RootCauseKey,NewField1)
     VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,ST_GeomFromGeoJson(?,1,4326),ST_GeomFromGeoJson(?,1,4326),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
         ON DUPLICATE KEY
     UPDATE Count         = Count + 1,
            Duration      = VALUES(LastReported) - FirstReported,
            EventCategory = VALUES(EventCategory),
            LastChanged   = VALUES(LastChanged),
            LastReported  = VALUES(LastReported),
            Severity      = VALUES(Severity),
            Summary       = VALUES(Summary),
            NewField1     = VALUES(NewField1)

[DATE TIME] [BINARY NAME]([PROCESS ID])<-> [INFO] Build Generic FieldSet as:
EventKey,EventCategory,EventType,Ack,Action,Actor,Count,Customer,Department,Details,DeviceType,Duration,EscalationFlag,ExpireTime,FirstReported,GeoPath,GeoLocation,IPAddress,LastChanged,LastReported,Location,Method,Node,OrigSeverity,OwnerName,RootCauseFlag,RootCauseID,Score,Service,ServiceImpact,Severity,SubDeviceType,SubMethod,SubNode,Summary,TicketFlag,TicketID,ZoneID,RootCauseKey,NewField1