# Elastic APM shows 100% CPU usage but the cause is unclear – need help!

**URL:** <https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173>\
**Category:** APM\
**Tags:** docker, java\
**Created:** [March 20, 2025, 10:21am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173 "2025-03-20T10:21:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![truongsontn96](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@truongsontn96](https://discuss.elastic.co/u/truongsontn96)\
**Post date:** [March 20, 2025, 10:21am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/1 "2025-03-20T10:21:42Z")

</div>

I am experiencing an issue with Elastic APM where the **system.cpu.total.norm.pct** metric for a specific service is always **1** , indicating that CPU usage is constantly at **100%** ,

However, when I check inside the container, I do not see the same behavior.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/3/939ab96f995d6570f8852c47a1aea9f2e776d638.png)

I've configured the Java Agent in the container as follows:

```auto
java -DXms1024M -Xmx1024M                  
                 -XX:+UseParallelGC -Xlog:gc:logs/gc.log
                 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
                 -javaagent:/opt/app/bin/elastic-apm-agent-1.47.1.jar
                 -Delastic.apm.service_name={backend-service}
                 -Delastic.apm.secret_token={secret_token}
                 -Delastic.apm.server_url=https://localhost:8200
                 -Delastic.apm.transaction_sample_rate=0.1
                 -Delastic.apm.cpu_count=2

```

Does anyone know what could be causing this issue?

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [March 20, 2025, 2:19pm UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/2 "2025-03-20T14:19:23Z")

</div>

Hi !

There is probably an issue with how the metric is captured by the agent here.

Before we dig any further are also a few unexpected things in your configuration that would be nice to fix:

- `-Delastic.apm.cpu_count=2` : I don't know this config option, do you know where it comes from ?
- `-Delastic.apm.server_url=https://localhost:8200` will make the agent send data to `localhost` which means unless there is an apm-server running within the container it's quite unlikely to send data anywhere.

---

<div class="post-metadata">

**Author:** ![truongsontn96](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@truongsontn96](https://discuss.elastic.co/u/truongsontn96)\
**Post date:** [March 21, 2025, 3:29am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/3 "2025-03-21T03:29:16Z")

</div>

Yes, I couldn’t find the parameter `-Delastic.apm.cpu_count=2` in Elastic either. I think the issue is that the Elastic Java Agent has misinterpreted the number of cores on my host machine, causing the CPU percentage to always appear high. So, I asked ChatGPT about how to configure it :D, and it provided me with that parameter—most likely, it just made it up.

Besides that, regarding your second point, I have correctly configured the data to be sent to my Elastic APM server, as you can see in the screenshot below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/b/9b4051e69b226b0a8233b767a24e99e40ef3de97.png)

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [March 21, 2025, 8:30am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/4 "2025-03-21T08:30:43Z")

</div>

The `system.cpu.total.norm.pct` metric is captured from the JMX interface [`OperatingSystemMXBean.getSystemCpuLoad`](https://docs.oracle.com/en/java/javase/17/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getSystemCpuLoad()) , as I see that you have configured settings to connect to the remote JMX interface, can you try to see what is the actual value of this MBean attribute with a tool like jconsole or visualvm ?

If the value read through JMX is consistent with what the agent reports, then it means the problem is in the JVM, what version are you using ? There has been [quite a few bugs](https://bugs.openjdk.org/browse/JDK-8133666?jql=text%20~%20%22getSystemCpuLoad%22) in this area, in particular when running in containers.

---

<div class="post-metadata">

**Author:** ![truongsontn96](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@truongsontn96](https://discuss.elastic.co/u/truongsontn96)\
**Post date:** [March 24, 2025, 10:36am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/5 "2025-03-24T10:36:14Z")

</div>

I checked the CPU usage through JConsole, and it appears to be at a normal level, which is different from what Elastic shows (always 100% CPU usage). What could be causing this issue?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/a/6af24b8a03a1110c229776ae275a6f0bed6a27be.png)

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [March 24, 2025, 11:22am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/6 "2025-03-24T11:22:11Z")

</div>

Hi,

Maybe you could try updating to the latest agent version to see if that makes a difference here. If that's still an issue we will need to investigate further.

---

<div class="post-metadata">

**Author:** ![truongsontn96](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@truongsontn96](https://discuss.elastic.co/u/truongsontn96)\
**Post date:** [March 25, 2025, 4:30am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/7 "2025-03-25T04:30:33Z")

</div>

I have tried upgrading the Elastic APM agent to version 1.52.2, but the CPU usage is still always at 100%...

---

<div class="post-metadata">

**Author:** ![truongsontn96](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@truongsontn96](https://discuss.elastic.co/u/truongsontn96)\
**Post date:** [March 25, 2025, 7:22am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/8 "2025-03-25T07:22:26Z")

</div>

I see that the CPULoad metric in MBean checked from JConsole is always at 1. May I ask if the Elastic Agent is using this metric?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e98462556231149427f029a3a6299cd59877165.png)

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [March 25, 2025, 8:21am UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/9 "2025-03-25T08:21:30Z")

</div>

That's definitely unexpected, the `CpuLoad` shown here is always at exactly 1.0000, which is definitely something off as it should be fluctuating a bit but not appear like a constant.

However, the agent [only uses `SystemCpuLoad`](https://github.com/search?q=repo%3Aelastic%2Fapm-agent-java%20getSystemCpuLoad&type=code) so the `CpuLoad` attribute is not used.

What is the exact version and provider of the JVM here ? It's still possible it could be a JVM bug, so to rule this out I would also recommend updating to the latest available to see if that makes a difference.

---

<div class="post-metadata">

**Author:** ![chnacib](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chnacib/32/144037_2.png) [@chnacib](https://discuss.elastic.co/u/chnacib)\
**Post date:** [July 7, 2025, 1:17pm UTC](https://discuss.elastic.co/t/elastic-apm-shows-100-cpu-usage-but-the-cause-is-unclear-need-help/376173/10 "2025-07-07T13:17:27Z")

</div>

I faced this issue last week and the cause can be the following:

Maybe your java is facing problem to detect available cpu core count in container, to fix this, try to add the flag `-XX:ActiveProcessorCount=2` (2 available cpu cores in my case).  
The VM normally determines the number of available processors from the operating system. This flag can be useful for partitioning CPU resources when running multiple Java processes in docker containers
