<p>I'll need to monitor java springboot containers on kubernetes.</p>
<p>I'll probably use the <a href="https://docs.datadoghq.com/fr/containers/kubernetes/installation/?tab=helm" rel="nofollow noreferrer">installation process using helm</a> to deploy the agent on the nodes.</p>
<p>I'll probably use the <a href="https://docs.datadoghq.com/getting_started/containers/autodiscovery/" rel="nofollow noreferrer">annotations on pods</a> to avoid configuration file managements</p>
<p>I saw in the documentation that there was a jar client that you can add to each pod to monitor the containers.</p>
<p>If I need to monitor a springboot application, do I have to install both the datadog agent on the nodes + the datadog agent on the pods to reach springboot
OR will the datadog agent on the nodes be allowed to monitor a springboot agent turning into a pod using only annotations and environnement variables ?</p>

<p>Datadog come with deployment and daemonset</p>
<ul>
<li>cluster agent (for Kubernetes metrics) deployment</li>
<li>daemonset (for traching and logs) daemonset</li>
</ul>
<pre><code>helm repo add datadog https://helm.datadoghq.com
helm repo update
helm install &lt;RELEASE_NAME&gt; -f values.yaml  --set datadog.apiKey=&lt;DATADOG_API_KEY&gt; datadog/datadog --set targetSystem=&lt;TARGET_SYSTEM&gt;
</code></pre>
<blockquote>
<p>This chart adds the Datadog Agent to all nodes in your cluster with a <strong>DaemonSet</strong>. It also optionally deploys the kube-state-metrics chart and uses it as an additional source of metrics about the cluster. A few minutes after installation, Datadog begins to report hosts and metrics.</p>
</blockquote>
<p><strong>Logs:</strong>
For logs and APM you need some extra config</p>
<pre><code>datadog:
  logs:
    enabled: true
    containerCollectAll: true
</code></pre>
<p><a href="https://docs.datadoghq.com/containers/kubernetes/log/?tab=helm" rel="nofollow noreferrer">data-k8-logs-collection</a></p>
<p>Once everything is done, then its time to add auto-discovery
again no need to install anything for auto-discovery, until you need <a href="https://docs.datadoghq.com/containers/kubernetes/apm/?tab=helm" rel="nofollow noreferrer">APM</a> (profiling)</p>
<p>All you need to add</p>
<pre><code>        ad.datadoghq.com/CONTAINER_NAME_TO_MONITOR.check_names: |
          [&quot;openmetrics&quot;]
ad.datadoghq.com/CONTAINER_NAME_TO_MONITOR.init_configs: |
          [{}]
ad.datadoghq.com/CONTAINER_NAME_TO_MONITOR.instances: |
          [
           {
              &quot;prometheus_url&quot;: &quot;http://%%host%%:5000/internal/metrics&quot;,
              &quot;namespace&quot;: &quot;my_springboot_app&quot;,
              &quot;metrics&quot;: [ &quot;*&quot; ]
            }
          ] 
</code></pre>
<p>replace <code>5000</code> with the port of the container listening. again this is required to push Prometheus/openmetrics to datadog.</p>
<p>If you just need logs, no need for any extra fancy stuff, just <code>containerCollectAll: true</code> this is enough for logs collection.</p>
<p><strong>APM</strong></p>
<p>You need add JAVA agent, add this in the dockerfile</p>
<pre><code>RUN wget --no-check-certificate -O /app/dd-java-agent.jar https://dtdg.co/latest-java-tracer
</code></pre>
<p>and then you need to update <code>CMD</code> to let the agent collect tracing/apm/profiling</p>
<pre><code>java -javaagent:/app/dd-java-agent.jar -Ddd.profiling.enabled=$DD_PROFILING_ENABLED -XX:FlightRecorderOptions=stackdepth=256 -Ddd.logs.injection=$DD_LOGS_INJECTION -Ddd.trace.sample.rate=$DD_TRACE_SAMPLE_RATE -Ddd.service=$DD_SERVICE -Ddd.env=$DD_ENV -J-server -Dhttp.port=5000 -jar sfdc-core.jar

</code></pre>
<p><a href="https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/java/?tab=containers" rel="nofollow noreferrer">trace_collection_java</a></p>
