Configuring core OpenShift Container Platform monitoring components

  • Edit the cluster-monitoring-config configmap object in the openshift-monitoring project.

  • Add your configuration under data/config.yaml as a key-value pair <component_name>: <component_configuration>.

    For more information about configurations options, see https://docs.redhat.com/documentation/openshift_container_platform/4.18/html/monitoring/config-map-reference-for-the-cluster-monitoring-operator#cluster-monitoring-operator-configuration-reference.

  • Configmap updates: enables userworkload and object configures a persistent volume claim (PVC) for Prometheus. This relates to the Prometheus instance that monitors core OpenShift Container Platform components only. Get the default OpenShift Container Platform storage class from the script below and then run the update command:

    if [[ -z "${PROJECT_CP4AIOPS}" ]]; then
      echo "ERROR: PROJECT_CP4AIOPS is not set"
      exit 1
    fi
    
    if [[ -z "${OCP_MONITOR_STORAGE_CLASS}" ]]; then
      OCP_MONITOR_STORAGE_CLASS=$(oc get sc -o jsonpath='{.items[?(@.metadata.annotations.storageclass\.kubernetes\.io/is-default-class=="true")].metadata.name}')
      if [[ -z "${OCP_MONITOR_STORAGE_CLASS}" ]]; then
        OCP_MONITOR_STORAGE_CLASS=$(oc get sc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep 'rbd$')
        if [[ -z "${OCP_MONITOR_STORAGE_CLASS}" ]]; then
          echo "ERROR: Could not find a suitable storage class for OCP Monitoring"
          exit $LINENO
        fi
      fi
    fi
    
  • Run the following command before running the script, or replace it with the Cloud Pak for AIOps namespace in the script.

    export PROJECT_CP4AIOPS=<aiops-namespace>
    
  • Execute the command to apply the changes:

    cat << EOF | oc apply --validate -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cluster-monitoring-config
      namespace: openshift-monitoring
    data:
      config.yaml: |
        enableUserWorkload: true
        prometheusK8s: 
          volumeClaimTemplate:
            spec:
              storageClassName: ${OCP_MONITOR_STORAGE_CLASS}
              volumeMode: Filesystem
              resources:
                requests:
                  storage: 40Gi