# Jenkins Pipeline Analytics using OpenTelemetry and Dynatrace

**URL:** <https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938>\
**Category:** Troubleshooting\
**Tags:** jenkins, opentelemetry\
**Created:** [September 27, 2024, 7:48am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938 "2024-09-27T07:48:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anton\_konikov](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anton\_konikov](https://community.dynatrace.com/u/anton_konikov)\
**Post date:** [September 27, 2024, 7:48am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/1 "2024-09-27T07:48:12Z")

</div>

## Prerequisites

- Jenkins as CI/CD tool
- OpenTelemetry plugin for Jenkins -&nbsp;[OpenTelemetry | Jenkins plugin](https://plugins.jenkins.io/opentelemetry/)
- Generate API token in scopes:&nbsp; **openTelemetryTrace.ingest** ,&nbsp; **metrics.ingest** ,&nbsp; **logs.ingest**.

To illustrate, we’ll employ Podman as our container runtime and set up Jenkins within it. For that, you could use the following command:

`podman run --name jenkins -d -e OTEL_LOGS_EXPORTER="otlp" -p 8080:8080 jenkins/jenkins:lts`

Once the container is up and running in your favorite browser, let’s navigate to&nbsp;[http://localhost:8080/](http://localhost:8080/)&nbsp;and, follow the shown instruction and login into Jenkins.

As the second step, from the main Jenkins view **Dashboard** , click on **Manage Jenkins** and then on **Plugins** :

 ![anton_konikov_0-1722499394570.png](https://global.discourse-cdn.com/dynatrace/original/2X/6/618e553f2d8eefa52d466eeea038972b2929e784.png)

On this step, let’s install OpenTelemetry plugin. Select **Available** pugins and type **OpenTelemetry** in the search bar. Select the [plugin](https://plugins.jenkins.io/opentelemetry/) and depending on the Jenkins version, press **Install** button or&nbsp; **Install without restart**.

 ![anton_konikov_1-1722499731965.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/e/8e1150572ec12293868c5b50c1a73c58b1353102.png)

After the installation is sucesfully finished, scroll down and select&nbsp; **Restart Jenkins when installation is complete and no jobs are running** :

 ![anton_konikov_2-1722501194250.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/0/70fcec8b52608930ac6e0337cc2f010b55c1a2f2.png)

## Configuration

Now let’s go to Dynatrace UI and generate an API token

From **Manage Jenkins** view, navigate to **System** configuration:

 ![anton_konikov_0-1722501769762.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/f/6fe7a2754a836f0a5196a77290df5a7a6659fb47.png)

Scroll to the OpenTelemetry section and in the **OTLP endpoint** sectrion specify your SaaS OTLP API endpoint, e.g.&nbsp;`https://{your-environment-id}.live.dynatrace.com/api/v2/otlp`, in the **Authentication** section, select **Header Authetication** and type in the filed&nbsp; **Header Name** :&nbsp;`Authorization`:

 ![anton_konikov_2-1722502592528.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/a/8a503f20ae343af6463b907cb85dabc759fef953.png)

For the&nbsp; **Header Value** , create a new secret tocken by seceting&nbsp; **Add** &nbsp;\>&nbsp; **Jenkins**. You’ll need to create a secret text with the following fields:

- For&nbsp; **Kind** , choose&nbsp; **Secret text**.
- The&nbsp; **Secret** &nbsp;field&nbsp;should be in the follwoing format:&nbsp;`Authorization: Api-Token dt.....`
- Optional field ID can be left blank.
- Optionally add a description such as&nbsp;`Dynatrace API ingest token`.

 ![anton_konikov_1-1722502456738.png](https://global.discourse-cdn.com/dynatrace/original/1X/e0400c8131fd8799da31b8f3a1d748cc84a7f65f.png)

Then scroll down to **Advanced** configuration and expand it. In the&nbsp; **Configuration properties** filed paste:&nbsp;`otel.exporter.otlp.protocol=http/protobuf`, as [gRPC is not yet supported](https://docs.dynatrace.com/docs/extend-dynatrace/opentelemetry/getting-started/otlp-export#otlp-details):

 ![anton_konikov_3-1722504113885.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/0/d03534f659d95b84effb14f496c76fc9fd016cda.png)

Additionally you can configure visualisation backend to show the link between build and trace in Dynatrace:

 ![anton_konikov_0-1722514523405.png](https://global.discourse-cdn.com/dynatrace/original/2X/8/89af7f7eff6e91a98f1359514393632e05aa08da.png)

## Receiving Jenkins data in Dynatrace

Please make sure that **OTLP Endpoint** set up earlier is accesible from Jenkins location. Let’s create the first test pipeline and verify the monitoring data can be observed.

Click on **New Item** and create the **Pipeline** job:

 ![anton_konikov_2-1722515216483.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/b/2b789afeb3ac231cfc7a94187c243aa80debbcc0.png)

 ![anton_konikov_1-1722515145554.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0c5a7eb207ddee97076bb6318b9a0fa96fa98952.png)

Then scroll down to the **Pipeline** configuration and select the **Github+Maven** sample or paste the bellow snippet:

```java
pipeline {
    agent any
    tools {
        // Install the Maven version configured as "M3" and add it to the path.
        maven "M3"
    }
    stages {
        stage('Build') {
            steps {
                // Get some code from a GitHub repository
                git 'https://github.com/jglick/simple-maven-project-with-tests.git'

                // Run Maven on a Unix agent.
                sh "mvn -Dmaven.test.failure.ignore=true clean package"

                // To run Maven on a Windows agent, use
                // bat "mvn -Dmaven.test.failure.ignore=true clean package"
            }
            post {
                // If Maven was able to run the tests, even if some of the test
                // failed, record the test results and archive the jar file.
                success {
                    junit '**/target/surefire-reports/TEST-*.xml'
                    archiveArtifacts 'target/*.jar'
                }
            }
        }
    }
}

```

 ![anton_konikov_0-1722591158716.png](https://global.discourse-cdn.com/dynatrace/original/2X/9/9adc0c33c81c5305bf1ed74d67214af710fa2495.png)

Note: the prerequisite is to install Maven, which requires defining Maven instance in the **Mange Jenkins** \> **Tools** :

 ![anton_konikov_1-1722591319581.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0524242f2243e403258061f31f9fa74e502e53c0.png)

After finishing the configuration of the pipeline job you can click on the **Build Now** button which then trigger execution of the pipeline:

 ![Screenshot 2024-08-02 at 11.40.01.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/4f94cbe2cc0f0ec53e11c5866ed5c97667adec40.png)  
As it can be seen in the screenshot above, under **OpenTelemetry** appeared a link navigating to the particular trace in Dynatrace UI. In the trace view you could see all logs from the Jenkins build by clicking on View logs for this trace or click on the particular trace sub-node/span and open **Logs** tab:  
 ![Screenshot 2024-08-02 at 11.56.31.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/4/34957aab5528931db71ccbe1eba644d64a4124ff.png)

 ![Screenshot 2024-08-02 at 12.00.22.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/43355ee72c634eff6f879ec72b258f1be544278a.png)

 ![Screenshot 2024-08-02 at 12.01.47.png](https://global.discourse-cdn.com/dynatrace/original/2X/3/34f4380655fe7288564638ca287f1055539dcf41.png)

Additionally, we encourage you to watch this demo session [Dynatrace Tips & Tricks #18 - Jenkins Pipeline Analytics with OpenTelemetry](https://community.dynatrace.com/topic/225200).

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [October 2, 2024, 3:22pm UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/2 "2024-10-02T15:22:25Z")

</div>

Hi&nbsp;[@anton\_konikov](https://community.dynatrace.com/user/5153)&nbsp;,

Can we use this solution on Managed environment with OTLP traces v1 api?

 ![Mizs_0-1727882482076.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/237cf2f10e1a81c7df03583db7deb2489d34e183.png)

Thanks in advance.

Best reagrads,

Mizső

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [October 3, 2024, 7:16am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/3 "2024-10-03T07:16:09Z")

</div>

[@Mizső](https://community.dynatrace.com/user/47783)&nbsp;yes, you can.

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [October 3, 2024, 8:02am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/4 "2024-10-03T08:02:07Z")

</div>

Hi&nbsp;[@Julius\_Loman](https://community.dynatrace.com/user/3364)&nbsp;,

Thanks for the confirmation.&nbsp;😉

Best regards,

Mizső

---

<div class="post-metadata">

**Author:** ![yniasreynders96](https://avatars.discourse-cdn.com/v4/letter/y/ee7513/32.png) [@yniasreynders96](https://community.dynatrace.com/u/yniasreynders96)\
**Post date:** [February 3, 2025, 9:28am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/5 "2025-02-03T09:28:02Z")

</div>

For those who get traces but no logs, we needed to add the following parameters to get the build logs.

```python
otel.exporter.otlp.protocol=http/protobuf
otel.instrumentation.jenkins.remote.span.enabled=true
otel.instrumentation.jenkins.agent.enabled=true
otel.logs.exporter=otlp
otel.logs.mirror_to_disk=true

```

---

<div class="post-metadata">

**Author:** ![hnimawat](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@hnimawat](https://community.dynatrace.com/u/hnimawat)\
**Post date:** [February 17, 2025, 5:16pm UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/6 "2025-02-17T17:16:30Z")

</div>

Hi&nbsp;[@Mizső](https://community.dynatrace.com/user/47783)

I am using Dynatrace Managed and did all the steps as mentioned here but still where I click on “openTelemetry” in Jenkins, it redirects me to our managed environment and shows “Trace Not Found”.

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [February 18, 2025, 5:00am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/7 "2025-02-18T05:00:48Z")

</div>

Hi&nbsp;[@hnimawat](https://community.dynatrace.com/user/86839),

We have not implemeted this soultion yet at our client. Sorry but I do not have further information about it.

Best regards,

János

---

<div class="post-metadata">

**Author:** ![anton\_konikov](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anton\_konikov](https://community.dynatrace.com/u/anton_konikov)\
**Post date:** [February 18, 2025, 8:56am UTC](https://community.dynatrace.com/t/jenkins-pipeline-analytics-using-opentelemetry-and-dynatrace/46938/8 "2025-02-18T08:56:08Z")

</div>

Hi&nbsp;[@hnimawat](https://community.dynatrace.com/user/86839),

Embedded OpenTelemetry knows the trace ID and substitutes it into the URL to your Managed. However, the trace was not exported to Dynatrace server.

This can happen e.g. when OpenTelemetry doesn’t trust your certificate of the endpoint, but the real issue you could see in the Jenkins logs.

The preferable solution would be to add this certificate for Jenkins/OTLP or alternatively, you can use a [Dynatrace OTLP collector](https://github.com/Dynatrace/dynatrace-otel-collector) as the middle point of the architecture to aggregate all OTEL data. Then add the certificate from your Managed to this collector or add an option to [skip TLS cert verify](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md#client-configuration) (as Dynatrace we recommend avoiding using this option).
