Thursday, November 21, 2024
HomeKubernetesArgoCDHow to Monitor ArgoCD using Prometheus

How to Monitor ArgoCD using Prometheus

Any given environment, it is important to monitoring. It helps to track the application/tool performance and also it helps to optimize the application. Similar, in a complex environment where we have numerous teams deploying both monoliths and microservices to Kubernetes, it’s almost a given that operations won’t always run perfectly. Argo CD provides us with a plenty of metrics that enable us to gauge system utilization, whether it’s under or over, and strategize necessary actions.

In this article, Will see about about how to monitor Argo CD using Prometheus. Given its robust focus on reliability, Prometheus stands out as one of the most effective tools for assessing your system’s current state and swiftly pinpointing potential issues.

kube-prometheus-stack

This is a collection of Kubernetes resources that make it easy to operate an instance of Prometheus in a Kubernetes cluster. It is designed to deliver both simple and comprehensive monitoring solutions for Kubernetes clusters.

It provides a predefined set of Grafana dashboards and Prometheus rules combined with community-driven best practices. The stack includes the following components:

  1. Prometheus: An open-source systems monitoring and alerting toolkit.
  2. Alertmanager: Handles alerts sent by client applications such as the Prometheus server, carefully de-duplicating, grouping, and routing them to the correct receiver.
  3. Node Exporter: A Prometheus exporter for hardware and OS metrics with pluggable metric collectors.
  4. kube-state-metrics: A service that listens to the Kubernetes API server and generates metrics about the state of the objects.
  5. Grafana: An open-source platform for monitoring and observability that lets you query, visualize, alert on, and understand your metrics.
  6. Prometheus Operator: Creates/configures/manages Prometheus clusters atop Kubernetes.

Prerequisites

  • Kubernetes 1.20+
  • Helm 3+

This post finds you have argocd installed and running already. If not, please follow: Setup ArgoCD on Azure Kubernetes Services – FoxuTech

Installation

Get Helm Repo Info

# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "prometheus-community" chart repository

Install Helm Chart

# helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring
NAME: prometheus
LAST DEPLOYED: Sat Jun 17 16:19:17 2023
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
  kubectl --namespace monitoring get pods -l "release=prometheus"

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.

ServiceMonitor

After the installation, we will need to tell Prometheus where it can find the endpoints that expose the metrics. To do that, we can use the custom ServiceMonitor resource. Apply the following resources:

# servicemonitor-argocd-metrics.yml

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: argocd-metrics
  labels:
    release: prometheus-operator
spec:
  selector:
    matchLabels:
     app.kubernetes.io/name: argocd-metrics
  namespaceSelector:
    any: true
  endpoints:
  - port: metrics

# servicemonitor-argocd-repo-server-metrics.yml

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: argocd-repo-server-metrics
  labels:
    release: prometheus-operator
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-repo-server
  namespaceSelector:
    any: true
  endpoints:
  - port: metrics

# servicemonitor-argocd-server-metrics.yml

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: argocd-server-metrics
  labels:
    release: prometheus-operator
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-server-metrics
  namespaceSelector:
    any: true
  endpoints:
  - port: metrics

After you run kubectl apply to all three YAML files above, the scraping process will begin. Now you should be able to import the Argo CD dashboard.

Access Grafana Dashboard

Note, the default user/password is admin/prom-operator

# kubectl port-forward -n monitoring prometheus-grafana-0b2xd7vfw-5zc2e 8080 --address 0.0.0.0
Forwarding from 0.0.0.0:8080 -> 8080

Now log into the Grafana dashboard, and start importing:

Import Argo CD dashboard from https://grafana.com/grafana/dashboards/14584-argocd/

Once imported, you should be able to see the Argo CD dashboard:

Pic from grafana.com

RELATED ARTICLES
- Advertisment -

Most Popular

Recent Comments