# Combine Two Metrics in One V2 Metrics API Call

**URL:** <https://community.dynatrace.com/t/combine-two-metrics-in-one-v2-metrics-api-call/50149>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [February 6, 2025, 8:05pm UTC](https://community.dynatrace.com/t/combine-two-metrics-in-one-v2-metrics-api-call/50149 "2025-02-06T20:05:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crabbylou](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@crabbylou](https://community.dynatrace.com/u/crabbylou)\
**Post date:** [February 6, 2025, 8:05pm UTC](https://community.dynatrace.com/t/combine-two-metrics-in-one-v2-metrics-api-call/50149/1 "2025-02-06T20:05:21Z")

</div>

Hello Community,

Is it possible to combine two metrics in an API call. They are not the same family.

builtin:containers.memory.limitBytes and builtin:kubernetes.workload.requests\_memory

with the search key being the Kubernetes namespace.

(Otherwise, I can probably make two calls and then merge the results.)

Any ideas would be appreciated.

Thanks,

Lou

---

<div class="post-metadata">

**Author:** ![JamesKitson](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jameskitson/32/22460_2.png) [@JamesKitson](https://community.dynatrace.com/u/JamesKitson)\
**Post date:** [February 6, 2025, 8:45pm UTC](https://community.dynatrace.com/t/combine-two-metrics-in-one-v2-metrics-api-call/50149/2 "2025-02-06T20:45:56Z")

</div>

I think you should be able to get what you want one way or another. In the [metrics get data points API](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-api/environment-api/metric-v2/get-data-points) call you can set metric selector in which you can specify [multiple metric selectors](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-api/environment-api/metric-v2/metric-selector) (separated by commas) or you can do [metric expressions](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-api/environment-api/metric-v2/metric-expressions) (i.e simple arithmetic).

If you query for multiple selectors you will have the results separate in the response (but with 1 call) and if you use an expression (e.g. metricA + metricB) the data points returned will be the result. You’ll want to make sure you are splitting by the same dimensions in each subselector.

e.g.

```markup
metricSelector: builtin:host.cpu.idle:splitBy("dt.entity.host") + builtin:host.cpu.system:splitBy("dt.entity.host")

```

Response:

```markup
{
  "totalCount": 2,
  "nextPageKey": null,
  "resolution": "Inf",
  "result": [
    {
      "metricId": "builtin:host.cpu.idle:splitBy(\"dt.entity.host\")+builtin:host.cpu.system:splitBy(\"dt.entity.host\")",
      "dataPointCountRatio": 0.0000242,
      "dimensionCountRatio": 0.00004,
      "data": [
        {
          "dimensions": [
            "HOST-5B4495AD33E8513B"
          ],
          "dimensionMap": {
            "dt.entity.host": "HOST-5B4495AD33E8513B"
          },
          "timestamps": [
            1738874700000
          ],
          "values": [
            99.52119439623269
          ]
        },
        {
          "dimensions": [
            "HOST-561B1E07CB771F4B"
          ],
          "dimensionMap": {
            "dt.entity.host": "HOST-561B1E07CB771F4B"
          },
          "timestamps": [
            1738874700000
          ],
          "values": [
            95.33600394990708
          ]
        }
      ]
    }
  ]
}

```
