IBM Support

How do I create my own custom reporting Attributes ?

Question & Answer


Question

How do I create my own custom reporting Attributes ?

Answer

IBM Guardium provides a GuardAPI set of functions via the Command Line Interface ( cli ) that allows for the creation of custom attributes.

Attributes are created within pre-defined Guardium Main Entities , for example

    • Session
    • Client/Server
    • FULL_SQL
    • Object

These custom attributes can then be selected as Fields or Condition within queries and reports.

There are 6 available functions related to the creation, update and deletion of custom Attributes. These are:

    • create_constant_attribute
    • delete_constant_attribute
    • update_constant_attribute
    • create_computed_attribute
    • delete_computed_attribute
    • update_computed_attribute

This article will demonstrate the use of the "create_computed_attribute" to create an attribute that will extract the "schema" or "owner" of a database table from a fully qualified sql statement that can then be reported upon.

The "create_computed_attribute" function has four input parameters:

attributeLabelThis is the name of the custom attribute. This will be the column heading in any subsequent reports generated
entityLabelThis equates to the "Main Entity" name that the attribute will be associated with i.e. Session, Object, FULL_SQL etc
expressionThis is an sql expression that will be used to generate the computed value for the new attribute
api_target_hostUsed for central management configuration only to specify a target host name or ip address.

We will call our new custom attribute MySchema1 and we will extract the schema ( or owner ) value from the Object_Name attribute value which is part of the Object main entity.



Given the following sql statement :
    select * from scott.tab1;

We expect the Object_Name field (attribute) in a report to be populated with the value "scott.tab1"

To extract the schema value from the Object_Name field, in this case "scott", we need to create an sql expression.

The following expression uses the sql function SUBSTRING_INDEX to return the sub-string value to the left of the first occurring full stop (period) ".". in the Object_Name field.


    SUBSTRING_INDEX(Object_Name,'.',1)
    Bringing all that together we form the following single grdapi command:


    grdapi create_computed_attribute attributeLabel="MySchema1" entityLabel="Object" expression="SUBSTRING_INDEX(Object_Name,'.',1)"


    Once this command has been run we are immediately able to view our new attribute under the Object main entity when creating reports.

    Here is an example of the output from a simple report displaying the MySchema1 attribute created above.


    Although this is a simple example, the same theory can be applied for any valid sql expression in order to create your own custom attributes for reporting purposes.

    Further details on each of the additional functions listed above can be found within the Guardium appliance "Help System" under the section entitled "GuardAPI Entity Functions ".

    [{"Product":{"code":"SSMPHH","label":"IBM Security Guardium"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Guardium Database Activity Monitor","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"}],"Version":"9.0;8.2;8.0.1","Edition":"All Editions","Line of Business":{"code":"LOB24","label":"Security Software"}}]

    Document Information

    Modified date:
    12 December 2019

    UID

    swg21623321