Collect Argo CD metrics by using managed service for Prometheus

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. Argo CD follows the GitOps pattern of using Git repositories as the source of truth for defining the desired application states. It automates the deployment of the desired application states in the specified target environments. Application deployments can track updates to branches or tags, or they can be pinned to a specific version of manifests at a Git commit.

This article describes how to configure the Azure Monitor managed service for Prometheus feature with Azure Kubernetes Service (AKS) and Azure Arc-enabled Kubernetes to monitor Argo CD by scraping Prometheus metrics.

Prerequisites

  • Argo CD running on AKS or Azure Arc-enabled Kubernetes
  • Managed service for Prometheus enabled on the cluster. For more information, see Enable Prometheus and Grafana.

Deploy service monitors

Deploy the following service monitors to configure the managed service for Prometheus add-on to scrape Prometheus metrics from the Argo CD workload.

Note

Specify the right labels in matchLabels for the service monitors if they don't match the configured ones in the sample.

apiVersion: azmonitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: azmon-argocd-metrics
spec:
  labelLimit: 63
  labelNameLengthLimit: 511
  labelValueLengthLimit: 1023
  selector:
    matchLabels:
     app.kubernetes.io/name: argocd-metrics
  namespaceSelector:
    any: true
  endpoints:
  - port: metrics
---
apiVersion: azmonitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: azmon-argocd-repo-server-metrics
spec:
  labelLimit: 63
  labelNameLengthLimit: 511
  labelValueLengthLimit: 1023
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-repo-server
  namespaceSelector:
    any: true
  endpoints:
  - port: metrics
---
apiVersion: azmonitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: azmon-argocd-server-metrics
spec:
  labelLimit: 63
  labelNameLengthLimit: 511
  labelValueLengthLimit: 1023
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-server-metrics
  namespaceSelector:
    any: true
  endpoints:
  - port: metrics

Note

If you want to configure any other service or pod monitors, follow these instructions.

Deploy rules

  1. Download the template file and the parameter file for alerting rules.

  2. Edit the following values in the parameter file.

    Parameter Value
    azureMonitorWorkspace Resource ID for the Azure Monitor workspace. Retrieve it from JSON view on the Overview page for the Azure Monitor workspace.
    location Location of the Azure Monitor workspace. Retrieve it from JSON view on the Overview page for the Azure Monitor workspace.
    clusterName Name of the AKS cluster. Retrieve it from JSON view on the Overview page for the cluster.
    actionGroupId Resource ID for the alert action group. Retrieve it from JSON view on the Overview page for the action group. Learn more about action groups.
  3. Deploy the template by using any standard methods for installing Azure Resource Manager templates. For guidance, see Resource Manager template samples for Azure Monitor.

  4. After you deploy the template, you can view the rules in the Azure portal. Review the alert thresholds to make sure that they suit your cluster and workloads. Update the thresholds accordingly.

If you want to use any other open-source Prometheus alerting/recording rules, use az-prom-rules-converter to create the Azure-equivalent Prometheus rules.

Import the Grafana dashboard

To import the Grafana dashboard for Argo CD (ID 14191) by using the ID or JSON, follow the instructions in Import a dashboard from Grafana Labs.

Troubleshoot

When the service monitors are successfully applied, if you want to make sure that the add-on picks up the service monitor targets, follow these instructions.