PostgreSQL metrics

Use the predefined PostgreSQL metrics to view information about the number of assembly and resource instances in IBM® Cloud Pak for Network Automation. You can also define custom PostgreSQL metrics to retrieve information such as active counts of Site Planner instance data.

When you install IBM Cloud Pak for Network Automation, some predefined PostgreSQL metrics are available automatically, and you can also define custom PostgreSQL metrics.
Predefined PostgreSQL metrics
The cp4na-o-postgresql-predefined-monitoring configmap is deployed automatically and contains the following PostgreSQL metrics. These metrics show active information about the number of assembly and resource instances:
Metric Description
cnp_assembly_instance_toplevel_count The number of higher-level assemblies in your orchestration instance.
cnp_assembly_instance_count The number of assembly instances.
cnp_resource_instance_count The number of resource instances.
Restriction: The cp4na-o-postgresql-predefined-monitoring configmap cannot be modified after installation.
Custom PostgreSQL metrics
You can define custom PostgreSQL metrics by adding SQL queries to the cp4na-o-postgresql-custom-monitoring configmap.
Tip:

You can add the custom SQL queries anytime and you don't need to restart pods or microservices to activate the metrics.

The following database tables and views can be used when you build your custom queries:
  • The v_topologyinstance view in the cp4na schema. The view includes the following columns:
    Column Type
    ID Integer
    Type String
    Top_level Boolean
    Example values for the Type column include ASSEMBLYINSTANCE, CLUSTERINSTANCE, and RESOURCEINSTANCE.
  • If Site Planner is installed, the custom tables that are generated by the Site Planner plug-ins can be used.

    The table names use the following format: <plugin-name>_<model-name>.

    Where:
    • <plugin-name> is the name of your Site Planner plug-in
    • <model-name> is the name of your model

    For example, if your plug-in that is named fiveg adds a model that is named SliceProfile, the table is named fiveg_sliceprofile.

Add or modify custom metrics by completing the following steps:
  1. Ensure that your instance of IBM Cloud Pak for Network Automation is in the Ready state before you edit the configmap. Run the following command:
    oc get orchestration -n <cp4na_namespace>

    <cp4na_namespace> is the namespace where IBM Cloud Pak for Network Automation is installed.

  2. Open the configmap for editing by running the following command:
    oc edit configmap cp4na-o-postgresql-custom-monitoring -n <cp4na_namespace>
  3. In the queries section of the configmap, add or modify metrics by using the format in the following example metric:
    cluster_instance:
      query: |
        SELECT COUNT(*) AS count FROM cp4na.V_TOPOLOGYINSTANCE WHERE TYPE = 'CLUSTERINSTANCE'
      metrics:
        - count:
            usage: "GAUGE"
            description: "Number of cluster instances"
      target_databases:
        - app
  4. Save the changes to the configmap.

    The new and modified metrics are shown automatically in the Prometheus output. The example metric, cluster_instance, is shown in Prometheus as cnp_cluster_instance_count.

  5. Optional: Verify that the updated metrics are in the configmap by running the following command:
    oc get configmap cp4na-o-postgresql-custom-monitoring -o yaml