×

By default, the Red Hat OpenShift GitOps Operator automatically detects an installed Argo CD instance in your defined namespace, for example, openshift-gitops, and connects it to the monitoring stack of the cluster to provide alerts for out-of-sync applications.

Prerequisites

  • You have access to the cluster with cluster-admin privileges.

  • You have access to the OpenShift Container Platform web console.

  • You have installed the Red Hat OpenShift GitOps Operator in your cluster.

  • You have installed an Argo CD application in your defined namespace, for example, openshift-gitops.

Monitoring Argo CD health using Prometheus metrics

You can monitor the health status of an Argo CD application by running Prometheus metrics queries against it.

Procedure
  1. In the Developer perspective of the web console, select the namespace where your Argo CD application is installed, and navigate to ObserveMetrics.

  2. From the Select query drop-down list, select Custom query.

  3. To check the health status of your Argo CD application, enter the Prometheus Query Language (PromQL) query similar to the following example in the Expression field:

    Example
    sum(argocd_app_info{dest_namespace=~"<your_defined_namespace>",health_status!=""}) by (health_status) (1)
    
    1 Replace the <your_defined_namespace> variable with the actual name of your defined namespace, for example openshift-gitops.

Disabling automatic scraping of metrics for Argo CD instances

By default, the Red Hat OpenShift GitOps Operator automatically scrapes metrics for all Argo CD instances to measure the performance. As a result, the Operator creates the following resources and label to the namespace where the Argo CD instance is installed:

  • gitops-operator-argocd-alerts prometheus rule

  • <argocd_namespace>-read role

  • <argocd_name>, <argocd_name>-repo-server, and <argocd_name>-server service monitors

  • <argocd_namespace>-prometheus-k8s-read-binding role binding

  • openshift.io/cluster-monitoring=true label

Scraping metrics for multiple Argo CD instances in a cluster might result in excessive storage usage. As a preventive measure, use the web console’s YAML view and configure the ArgoCD custom resource (CR) to disable the automatic scraping of metrics for your Argo CD instance.

As a cluster administrator, by disabling metric scraping for individual instances, you can give your users better control, flexibility, and stability to manage their defined namespaces.

Procedure
  1. Log in to the OpenShift Container Platform web console.

  2. In the Administrator perspective of the web console, click OperatorsInstalled Operators.

  3. From the Project list, select the project where the user-defined Argo CD instance is installed.

  4. Select Red Hat OpenShift GitOps from the installed Operators list and go to the Argo CD tab.

  5. Click your user-defined Argo CD instance.

  6. Configure the ArgoCD CR of your user-defined Argo CD instance to disable the automatic scraping of metrics:

    1. Click the YAML tab and edit the YAML file of the ArgoCD CR.

    2. In the ArgoCD CR, set the spec.monitoring.disableMetrics field value to true:

      Example ArgoCD CR
      apiVersion: argoproj.io/v1beta1
      kind: ArgoCD
      metadata:
       name: example  (1)
       namespace: spring-petclinic (2)
      spec:
       monitoring:
         disableMetrics: true
      1 The name of the user-defined Argo CD instance.
      2 The namespace where you want to run the user-defined Argo CD instance.

      Alternatively, use the following command to disable the automatic scraping of metrics in the Red Hat OpenShift GitOps argocd CLI:

      Example command
      $ oc patch argocd example -n spring-petclinic --type='json' -p='[{"op": "replace", "path": "/spec/monitoring/disableMetrics", "value": true}]'
      Example output
      argocd.argoproj.io/example patched
  7. Verify that the Operator adds the openshift.io/cluster-monitoring=false label to your defined namespace:

    1. Go to AdministrationNamespaces.

      The Namespaces page displays the created namespaces.

    2. Click your defined namespace, go to the YAML tab, and verify that under the metadata.labels section, the openshift.io/cluster-monitoring=false label is added by the Operator.

  8. Verify that the Operator deletes the following resources from your defined namespace:

    1. Go to HomeSearch.

    2. From the Resources list, select PrometheusRule, Role, RoleBinding, and ServiceMonitors.

      The Search page displays the selected resources.

    3. In the Search page, verify that under the PrometheusRule section, the gitops-operator-argocd-alerts prometheus rule is removed.

    4. Under the Roles section, from the Filter list, select Namespace Roles.

    5. Verify that the <argocd_namespace>-read role is removed.

    6. Under the RoleBindings section, from the Filter list, select Namespace RoleBindings.

    7. Verify that the <argocd_namespace>-prometheus-k8s-read-binding role binding is removed.

    8. Verify that under the ServiceMonitors section, the <argocd_name>, <argocd_name>-repo-server, and <argocd_name>-server service monitors are removed.

You can enable the metrics for your instance by modifying the spec.monitoring.disableMetrics field value to false. The Operator then creates the required role, role bindings, and service monitors and adds the openshift.io/cluster-monitoring=true label to your defined namespace.