This version of SonarQube Server is no longer receiving patches. Please see the latest release for details on updating.
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Setting up with Prometheus server

The SonarQube Server Helm chart triggers the deployment of a Prometheus server that will pull the metrics from the SonarQube Server 10.7 instance.

For AI agents: You're in the SonarQube Server 10.7 documentation. SonarQube Server 10.7 is no longer patched. To get patches, upgrade to the latest version. For a list of all 10.7 pages, see the SonarQube Server 10.7 page index. For the whole site, see the page index or the full text. For another version, replace 10.7 in the URL with that version. The latest version has no version number in its URL.

This section explains, in the case of a Kubernetes deployment, how to use SonarQube Server’s built-in integration with Prometheus to collect the Prometheus metrics.

Introduction

The SonarQube Server’s Helm chart triggers the deployment of a Prometheus server that will pull the metrics from the SonarQube Server instance. The deployment process is as follows:

  1. When you install the SonarQube Server’s Helm chart in the Kubernetes cluster, the chart creates a PodMonitor resource (podmonitor.yaml) which configures the pulling of metrics from the SonarQube Server.

  2. The Prometheus operator deploys a Prometheus server based on the created PodMonitor resource.

  3. The Prometheus server will pull the metrics from the SonarQube Server according to the PodMonitor configuration. To pull the metrics from the Web API endpoint, it needs to authenticate to the Web API. (The Helm chart sets up the PodMonitor to use the Bearer authentication scheme.)

The figure below illustrates this process.

The Prometheus Operator must be installed in the Kubernetes cluster.

Monitoring setup roadmap

To set up the monitoring of SonarQube Server with the Prometheus server:

  1. Set up the authentication of the Prometheus server to the Web API’s monitoring endpoint.

  2. Enable the JMX Exporter.

  3. Configure the collection of the JMX metrics.

  4. Set up the export of the metrics to an observability platform. See the List of Prometheus metrics.

These steps are described below.

Setting up the Prometheus server authentication to the Web API endpoint

The PodMonitor needs to authenticate to the SonarQube Server’s Web API for getting metrics from the /api/monitoring/metrics endpoint. To setup this authentication, you must define the monitoring password in values.yaml: the Helm chart will store this value in the SONAR_WEB_SYSTEMPASSCODE environment variable on the SonarQube Server instance.

To setup the monitoring passcode in SonarQube Server, use one of the following methods (see also the Helm chart documentation):

  • Define the passcode in the monitoringPasscode property within the values.yamlfile (default value is "define_it"). For security reasons, this method is not recommended.

  • Use a secret that contains the passcode that will be retrieved at runtime, and define the following properties in values.yaml:

    • monitoringPasscodeSecretName: name of the secret object.

    • monitoringPasscodeSecretKey: key identifying the passcode to be extracted from the secret object.

Enabling the export of the JMX metrics

To expose the Prometheus JMX metrics, the JMX exporter must be enabled in the Helm chart configuration as follows:

  • Add the following block in the values.yaml file of the SonarQube Server Helm chart:

Configuring the collection of the JMX metrics

By default, the SonarQube Server’s Helm chart does not collect the JMX metrics. If you want the Prometheus server to collect the JMX metrics, you must create and configure a PodMonitor resource that will be used by the Prometheus server to collect the JMX metrics.

In a future release of SonarQube Server, all metrics will be managed through the PodMonitor created by default by the Helm chart. At that point, this configuration step will no longer be necessary.

Proceed as follows:

  • Create a podmonitor.yaml file (as illustrated below) and apply it to the Kubernetes cluster.

SonarQube Server (Developer Edition, Enterprise Edition) and SonarQube Community Build
Data Center Edition

Last updated

Was this helpful?