> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-server/10.7/setup-and-upgrade/deploy-on-kubernetes/set-up-monitoring/datadog.md).

# Setting up with Datadog

In case of a Kubernetes deployment, you can use Datadog to collect the metrics provided through the Web API of SonarQube Server 10.7 (Openmetrics format).

{% hint style="info" %}
**For AI agents:** You're in the SonarQube Server 10.7 documentation. For a list of all 10.7 pages, see the [SonarQube Server 10.7 page index](https://3272878703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FI10pmJWeVVXYITlQJllp%2Fuploads%2FnEeIaIlHm7ezec5g9iHc%2Fsonarqube-server-10.7-llms.txt?alt=media). For the whole site, see the [page index](https://docs.sonarsource.com/llms.txt) or the [full text](https://docs.sonarsource.com/llms-full.txt). For another version, replace 10.7 in the URL with that version. The [latest version](https://docs.sonarsource.com/sonarqube-server/) has no version number in its URL.
{% endhint %}

This section explains, in case of a Kubernetes deployment, how to set up the collection by Datadog of the metrics provided through the SonarQube Server’s Web API (Openmetrics format). In the following, we assume that you are installing both SonarQube Server and Datadog to a Kubernetes cluster via the corresponding Helm charts.

## Introduction <a href="#introduction" id="introduction"></a>

To set up Datadog to monitor SonarQube Server, you have to specify an annotation in SonarQube Server’s Helm chart related to Datadog. Since Datadog doesn’t understand Prometheus’ Bearer authentication annotation, you cannot use it. Instead, you can specify an annotation that will manage a Datadog configuration file.

The illustration below shows the setup and monitoring process:

* When you install the SonarQube Server’s Helm chart in the Kubernetes cluster, the chart deploys the Datadog configuration file on the SonarQube Server Pod.
* The Datadog agent then:
  1. Reads the Datadog configuration file.
  2. Authenticates to the SonarQube Server’s Web API endpoint and pulls the Prometheus metrics from the endpoint.
  3. Pushes the metrics to the Datadog dashboard.

![](https://3272878703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FI10pmJWeVVXYITlQJllp%2Fuploads%2Fgit-blob-e99c06123b6ef7981cd6c55ac9b3089b37b05013%2F35f81efc01c95e9b076ab7e733716e9b0653d5de.png?alt=media)

## Setting up the Datadog authentication to the Web API endpoint <a href="#authentication" id="authentication"></a>

You need to create a secret containing the monitoring passcode and then mount that secret in the Datadog agent. To do so, add the code below to the `values.yaml` file of the Datadog’s Helm chart. In this example, we mount the subkey `passcode` from the `datadog-api-secret` secret into `/etc/secret-volume`.

```css-79elbk
agents:

 volumes:

 - name: secret-volume

   secret:

     secretName: datadog-api-secret

     items:

     - key: passcode

       path: passcode

 volumeMounts:

 - name: secret-volume

   mountPath: /etc/secret-volume
```

## Specifying the annotation for the Datadog agent <a href="#annotation" id="annotation"></a>

Add the code below to the `values.yaml` file of the SonarQube Server’s Helm chart. Note that:

* This example corresponds to the example shown shown in **Setting up the Datadog authentication to the Web API endpoint** above: you must adapt the `reader`and `writer`sections to your values.
* If a webcontext is used in the path at which to serve SonarQube Server then you must add it to the `openmetrics_endpoint`. For example, if the`/sonarqube` web context were used here then we would have:\
  `"openmetrics_endpoint": "http://%%host%%:9000/sonarqube/api/monitoring/metrics"`

```css-79elbk
# Set annotations for pods

annotations:

 #ad.datadoghq.com/<EXPECTED_POD_NAME>.checks  

 ad.datadoghq.com/sonarqube-dce.checks: |

     {

       "openmetrics": {

         "init_config": {},

         "instances": [

           {

             "openmetrics_endpoint": "http://%%host%%:9000/api/monitoring/metrics",

             "metrics": [".*"],

             "auth_token": 

             {

               "reader": 

               {

                 "type": "file",

                 "path": "/etc/secret-volume/passcode"

               },

               "writer":

               {

                 "type": "header",

                 "name": "Authorization",

                 "value": "Bearer <TOKEN>"

               }

             }

           }

         ]

       }

     }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-server/10.7/setup-and-upgrade/deploy-on-kubernetes/set-up-monitoring/datadog.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
