Monitoring the PostgreSQL datastore for Watson Speech services

You can enable monitoring of the PostgreSQL datastore to receive updates on its usage and status by the Watson Speech services. The events can be consumed by Prometheus monitoring software or whatever application you use for monitoring.

Permissions you need for these tasks:
You must have login credentials for the cluster.
You must have the name of the project (the namespace) for your deployment, which you can obtain from your cluster administrator.

Monitoring the PostgreSQL datastore

By enabling monitoring for user-defined projects in addition to the default platform monitoring, you can monitor your own projects with the Red Hat® OpenShift® Container Platform monitoring stack.

  1. Set the property spec.global.datastores.postgressql.enablePodMonitor to true in the Speech services custom resource. This causes the Speech operator to set the property spec.monitoring.enablePodMonitor to true in the PostgreSQL custom resource. The PostgreSQL operator creates a PodMonitor object that watches the PostgreSQL pods for metrics and makes them available to the Red Hat OpenShift Container Platform monitoring stack

    oc patch watsonspeech ${CUSTOM_RESOURCE_SPEECH} --type='json' \
       -p='[{"op": "add", "path": "/spec/global", "value":{"datastores":{"postgressql":{"enablePodMonitor": "true"}}}}]'
  2. Create the cluster-monitoring-config configmap and set enableUserWorkload to true under data/config.yaml. (If the configmap already exists, this command overwrites it.) When set to true, the enableUserWorkload parameter enables monitoring for user-defined projects in a cluster.

    cat << EOF | oc apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cluster-monitoring-config
      namespace: openshift-monitoring
    data:
      config.yaml: |
        enableUserWorkload: true
    EOF
  3. Set openshift.io/user-monitoring to true for the IBM Cloud Pak for Data project (namespace). This enables user monitoring when the Network Policy is created.

    oc label namespace ${PROJECT_CPD_INST_OPERANDS} openshift.io/user-monitoring=true
  4. Create a Network Policy to allow Prometheus to monitor the PodMonitor resource in the instance namespace. This allows the project to accept connections from the Red Hat OpenShift Container Platform monitoring stack.

    cat << EOF | oc apply -f -
    kind: NetworkPolicy
    apiVersion: networking.k8s.io/v1
    metadata:
      name: allow-from-openshift-monitoring
      namespace: ${PROJECT_CPD_INST_OPERANDS}
    spec:
      ingress:
      - from:
        - namespaceSelector:
           matchLabels:
             network.openshift.io/policy-group: monitoring
      podSelector: {}
      policyTypes:
      - Ingress
    EOF
  5. Ensure that you can see the PostgreSQL metrics from your monitoring stack. For a list of predefined metrics that are exposed by PostgreSQL and for information about how to define your own metrics, see Monitoring in the EDB PostgreSQL for Kubernetes documentation.