# Change of units in metrics

**URL:** <https://community.dynatrace.com/t/change-of-units-in-metrics/49733>\
**Category:** Extensions\
**Tags:** dynatrace-managed, jmx, extensions\
**Created:** [January 15, 2025, 2:42pm UTC](https://community.dynatrace.com/t/change-of-units-in-metrics/49733 "2025-01-15T14:42:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lubrman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/lubrman/32/7353_2.png) [@lubrman](https://community.dynatrace.com/u/lubrman)\
**Post date:** [January 15, 2025, 2:42pm UTC](https://community.dynatrace.com/t/change-of-units-in-metrics/49733/1 "2025-01-15T14:42:06Z")

</div>

As part of Extension 2.0, I am monitoring JMX metrics generated by an application.

One of the metrics has the displayName:&nbsp; **DirectBufferPool Memory Used** , which is generated in bytes. However, within the extension, I would like to perform a conversion and display the metric in megabytes.

I have tried modifying the unit settings in the documentation, but none of the changes have produced the expected result. Instead, incorrect unit calculations occur. For example, when the base value is 30 million bytes:

- Conversion to&nbsp; **Megabytes** &nbsp;results in&nbsp; **10 TB**.
- Conversion to&nbsp; **Kilobytes** &nbsp;results in&nbsp; **30 MB**.

```auto
- podskupina: java.nio:name=direct,*
      dotaz: java.nio:name=direct,*
      metriky:
      - klíč: java-nio.direcbufferpool.memory
        hodnota: atribut:Použitá paměť
        typ: měřidlo
 metricTableCards: []
- entityType: HOST
  podrobnosti Injekce:
  - typ: METRIC_TABLE
    klíč: metrictable-jmx-multiple_services
    podmínky:
    - metricAvailable|metric=dsfm:extension.status:filter(and(eq("dt.extension.name","custom:jmx.multiple_services"),in("dt.entity.host", entitySelector("entityId($ (entityId))))))|lastWrittenWithinDays=5
  metricTableCards:
    - displayName: DirecBufferPool Použitá paměť
      typ vizualizace: GRAPH_CHART
      graphChartConfig:
        naskládaný: falešný
        metriky:
        - metricSelector: java-nio.direcbufferpool.memory:splitBy()
metriky:
- klíč: java-nio.direcbufferpool.memory
  metadata:
    displayName: DirecBufferPool Použitá paměť
    popis: DirecBufferPool Memory Used
    jednotka: Byte
    sourceEntityType: instance_group_processu
    značky:
    - JMX

```

---

<div class="post-metadata">

**Author:** ![david\_lopes](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/david_lopes/32/27273_2.png) [@david\_lopes](https://community.dynatrace.com/u/david_lopes)\
**Post date:** [January 17, 2025, 1:10am UTC](https://community.dynatrace.com/t/change-of-units-in-metrics/49733/2 "2025-01-17T01:10:38Z")

</div>

You can’t change the metric itself since it is retrieved in Bytes

What you can do is change the visualization in dashboards, alerts, etc, anywhere where you can use a metric selector by using the [to Unit](https://docs.dynatrace.com/docs/shortlink/api-metrics-v2-selector#to-unit) operation, converting Bytes to something else.
