Sometimes the resourceID for the KPIs can have multiple parts and it might be that only
one part is displayed, thus making some alerts appear as duplicate entries in the
Alerts list. Learn how to configure the fields available to
display.
About this task
Some data in metric anomaly alerts is in an EventData field, and it can be
useful in some cases to put this data into a column of its own in the ObjectServer. To put the data
into a column of its own in the ObjectServer, add the columns and trigger as described in the
following section. Sometimes, the resourceID for the KPIs can have multiple parts. For example, if
you are monitoring multiple servers that support a service, then your resourceIDs might be a
combination of the service and the server names. The Node attribute might be
set to the service name. The value of the Node attribute appears in the
Node column, but the other part of the resourceID does not appear in any column
name. If an anomaly occurs, it might be difficult to identify the server that is affected. To
display affected server, include either the AnomalousResource field or the
specific attribute that contains the server value in the SQL file. If you want to create a
scope-based grouping on the server (that is to group alerts that co-occur and have the same server)
include the specific attribute that contains the server value.
Procedure
Consider the following example:
- Go to the
ncoprimary
pod. Find the ncoprimary
pod, by
running the following commands: oc get pod | grep ncoprimary
then
oc exec -ti <ncoprimary pod> -- bash
- Create a file named set_up_CN_objserv_for_MM_events.sql with the
following content:
- AnomalousMetric might be omitted, as it is already in the
AlertGroup field.
- AnomalousResource might be omitted, if you are including all of the other
attributes. But, if the other attributes are not available then it might be good to include the
whole resource name in one column.
- The names AnomalousCustomAttribute1,
AnomalousCustomAttribute2, ...
AnomalousCustomAttributeN must be updated to match the attribute names in the
JSON data that is sent to metric anomaly
detection.
- If you include AnomalousResource, then you might still choose to include
one or more of the custom attributes.
- If you have longer names, you might set varchar(255) to a higher value.
echo "alter table alerts.status add column AnomalousMetric varchar(255);" > /tmp/set_up_CN_objserv_for_MM_events.sql
echo "alter table alerts.status add column AnomalousResource varchar(255);" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "alter table alerts.status add column AnomalousCustomAttribute1 varchar(255);" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "alter table alerts.status add column AnomalousCustomAttribute2 varchar(255);" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "alter table alerts.status add column AnomalousCustomAttributeN varchar(255);" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "go" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "create or replace trigger group metricmanager_triggers;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "go" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "alter trigger group metricmanager_triggers set enabled true;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "go" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "create or replace trigger metric_info_to_fields" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "group metricmanager_triggers" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "priority 1" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "comment 'Pull values from the JSON in the EventData fields to populate their own fields'" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "before insert on alerts.status" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "for each row" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "begin" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " if (json_prop_get(new.EventData, 'resource.resource') != '') then" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " set new.AnomalousResource = json_prop_get(new.EventData, 'resource.resource');" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " set new.AnomalousMetric = json_prop_get(new.EventData, 'resource.metric');" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " if (json_prop_get(new.EventData, 'resource.AnomalousCustomAttribute1') != '') then" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " set new.subResource = json_prop_get(new.EventData, 'resource.AnomalousCustomAttribute1');" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " end if;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " if (json_prop_get(new.EventData, 'resource.AnomalousCustomAttribute2') != '') then" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " set new.subResource = json_prop_get(new.EventData, 'resource.AnomalousCustomAttribute2');" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " end if;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " if (json_prop_get(new.EventData, 'resource.AnomalousCustomAttributeN') != '') then" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " set new.subResource = json_prop_get(new.EventData, 'resource.AnomalousCustomAttributeN');" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " end if;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo " end if;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "end;" >> /tmp/set_up_CN_objserv_for_MM_events.sql
echo "go" >> /tmp/set_up_CN_objserv_for_MM_events.sql
- Apply the SQL file by using the following command:
/opt/IBM/tivoli/netcool/omnibus/bin/nco_sql -u root -p $OMNIBUS_ROOT_PWD -s AGG_P < /tmp/set_up_CN_objserv_for_MM_events.sql
- Repeat step 1-3 for the
ncobackup
pod.