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:
-
Edit the value of
global.crow.config.passwordAuth.password
in thevalues-production.yaml
file that you used to install Codacy:global: crow: config: passwordAuth: password: C0dacy123
-
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 filevalues-production.yaml
.To do this, uncomment the last line before running the
helm upgrade
command below.helm upgrade (...options used to install Codacy...) \ --version 7.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 the components in this monitoring stack.
1. Installing Prometheus#
The simplest way to set up Prometheus in your cluster is by using the Prometheus Operator bundle.
Add the custom resources required for installing this bundle in your cluster:
Important
If you're using MicroK8s use microk8s.kubectl
instead of kubectl
.
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml"
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml"
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml"
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml"
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml"
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/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 loki https://grafana.github.io/loki/charts
kubectl create namespace monitoring
helm upgrade --install --atomic --timeout 600s loki loki/loki \
--version 0.28.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 loki/promtail \
--version 0.22.2 --namespace monitoring --values values-promtail.yaml
4. Installing Prometheus and Grafana#
Obtain the configuration file for the Prometheus Operator bundle, values-prometheus-operator.yaml
. Then:
-
Edit the Grafana password for the
admin
user and the hostname for Grafana in thevalues-prometheus-operator.yaml
file. -
Install the bundle on your cluster by running the command below.
helm upgrade --install --atomic --timeout 600s monitoring stable/prometheus-operator \
--version 8.13.8 --namespace monitoring --values values-prometheus-operator.yaml
Follow the Kubernetes documentation to access the Grafana service that's 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.
-
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
-
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 7.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?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
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.