Example - Specific Child CI Group Rule

The following rule calculates KPI status based on the Availability KPI of a specific child CI (RTSM ID = "96c2df2b544683c7f79bb382d1d7b3a9").

If the child CI's Availability KPI value is 100, the calculated KPI's status is set to OK. All other values set the KPI's status to Critical.

Status is set only if the child CI exists, has the Availability KPI, and its Availability KPI has value.

public void calculateKPI(CI ci, KPI kpi) {
    /**
    * Get the Availability KPI for the child CI "tx_10 from virtual_host_3".
    * The RTSM ID of "tx_10 from virtual_host_3" is "96c2df2b544683c7f79bb382d1d7b3a9".
    *
    * Note: Within the UI, the following line can be written as
    * KPI childKPI = "tx_10 from virtual_host_3"."Availability"
    */
    KPI childKPI = ci.getChildKpiByChildId(KpiType.Availability, "96c2df2b544683c7f79bb382d1d7b3a9");
    
    // Check if childKPI is not null. It is null if no child CI with this RTSM ID exists, or if this CI does not have the Availability KPI.
    if (childKPI != null) {
    
        // Check if the child KPI has a value.
        if (childKPI.valueExist) {
            if (childKPI.value == 100.0) {
                kpi.status = Status.OK
        }
        else {
                kpi.status = Status.CRITICAL
            }
        }
    }
}


Parent topic: Examples - API Group and Sibling Rule