Skip to content
This documentation applies to Codacy Self-hosted v11.0.0

For the latest updates and improvements, see the latest Cloud documentation instead.

Monitoring#

Currently, Codacy Self-hosted supports two monitoring solutions:

  • Crow: A simple, lightweight, and built-in monitoring solution, enabled by default when you install Codacy.
  • Prometheus + Grafana + Loki: A comprehensive third-party monitoring solution, recommended for more advanced usage.

The sections below provide instructions on how to set up each monitoring solution.

Setting up monitoring using Crow#

Crow displays information about the projects that are pending analysis and the jobs currently running on Codacy.

Crow is installed alongside Codacy when the Helm chart is deployed to the cluster. By default, you can access Crow as follows:

  • URL: http://<codacy hostname>/monitoring, where <codacy hostname> is the hostname of your Codacy instance
  • Username: codacy
  • Password: C0dacy123

We highly recommend that you define a custom password for Crow, if you haven't already done it when installing Codacy:

  1. Edit the value of global.crow.config.passwordAuth.password in the values-production.yaml file that you used to install Codacy:

    global:
      crow:
        config:
          passwordAuth:
            password: C0dacy123
    
  2. Apply the new configuration by performing a Helm upgrade. To do so execute the command used to install Codacy:

    Important

    If you're using MicroK8s you must use the file values-microk8s.yaml together with the file values-production.yaml.

    To do this, uncomment the last line before running the helm upgrade command below.

    helm upgrade (...options used to install Codacy...) \
                 --version 11.0.0 \
                 --values values-production.yaml \
                 # --values values-microk8s.yaml
    

Setting up monitoring using Grafana, Prometheus, and Loki#

Prometheus is an open-source systems monitoring and alerting toolkit. Logs can be collected using Loki, which is a horizontally-scalable, highly-available, multi-tenant log aggregation system. Its data can be visualized with Grafana, a widely used open source analytics and monitoring solution.

This solution is considerably more resource demanding than Crow, and is recommended only for more advanced usage. Furthermore, its installation, configuration, and management require a deeper knowledge of Kubernetes as each component must be carefully tweaked to match your specific use case, using as starting point the .yaml values files provided by us.

The instructions below cover the basic installation of these monitoring services using the Kube Prometheus Stack.

Important

If you're using MicroK8s run alias kubectl=microk8s.kubectl.

1. Install custom resources#

Add the custom resources required for installing the monitoring bundle in your cluster:

kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml

2. Installing Loki#

Obtain the configuration file for Loki, values-loki.yaml, and install it by running the command below. While the default storage class setting for Loki persistence should suit most use cases, you may need to adjust it to your specific Kubernetes installation. For instance, for MicroK8s use storageClassName: microk8s-hostpath.

helm repo add grafana https://grafana.github.io/helm-charts

kubectl create namespace monitoring

helm upgrade --install --atomic --timeout 600s loki grafana/loki \
  --version 2.14.1 --namespace monitoring --values values-loki.yaml

3. Installing Promtail#

Promtail is an agent that ships the contents of local logs to a Loki instance.

Obtain the configuration file for Promtail, values-promtail.yaml, and install it by running the command below.

helm upgrade --install --atomic --timeout 600s promtail grafana/promtail \
  --version 2.2.0 --namespace monitoring --values values-promtail.yaml

4. Installing Prometheus and Grafana#

Obtain the configuration file for the Kube Prometheus Stack, values-prometheus-operator.yaml. Then:

  1. Edit the Grafana password for the admin user and the hostname for Grafana in the values-prometheus-operator.yaml file.

  2. Install the bundle on your cluster by running the command below.

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

helm upgrade --install --atomic --timeout 600s monitoring  prometheus-community/kube-prometheus-stack \
  --version 39.9.0 --namespace monitoring --values values-prometheus-operator.yaml

Grafana will be available on the domain you configured in your values-prometheus-operator.yaml file, with Prometheus and Loki configured as datasources. Follow the Kubernetes documentation if you need to access other monitoring services that are now running on your cluster, using the method that best suits your use case.

5. Enable service dashboards#

Now that you have Prometheus and Grafana installed you can enable metrics reporting for Codacy components.

  1. Create a file named values-monitoring.yaml with the following content:

    global:
      metrics:
        kamon:
          enabled: true
          prometheusReporter:
            enabled: true
        serviceMonitor:
          enabled: true
        grafana:
          enabled: true
    
  2. Apply this configuration by performing a Helm upgrade. To do so append --values values-monitoring.yaml to the command used to install Codacy:

    helm upgrade (...options used to install Codacy...) \
                 --version 11.0.0 \
                 --values values-monitoring.yaml
    

Share your feedback 📢

Did this page help you?

Thanks for the feedback! Is there anything else you'd like to tell us about this page?

We're sorry to hear that. Please let us know what we can improve:

Alternatively, you can create a more detailed issue on our GitHub repository.

Thanks for helping improve the Codacy documentation.

If you have a question or need help please contact support@codacy.com.

Last modified September 13, 2022