# Metrics API v2 - unit State

**URL:** <https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822>\
**Category:** Dynatrace API\
**Tags:** dynatrace-managed, dynatrace-api\
**Created:** [March 14, 2023, 4:40pm UTC](https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822 "2023-03-14T16:40:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [March 14, 2023, 4:40pm UTC](https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822/1 "2023-03-14T16:40:26Z")

</div>

Hi all,

I will enrich the metrics of various hosts using [Metrics API v2](https://www.dynatrace.com/support/help/shortlink/api-metrics-v2-post-datapoints).

One of the metrics is a state metric: Up, down, surveillance,…

I can use another API but the Metrics v2 are the only that I found able to send metrics to Hosts and not custom devices.

I know that I can change the unit using&nbsp;dt.meta.unit=“State” but now Im facing a wall on how to proceed.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 14, 2023, 5:07pm UTC](https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822/2 "2023-03-14T17:07:07Z")

</div>

Hi [@rdinis](https://community.dynatrace.com/user/58355) also you can ingest Host metrics through the&nbsp;[OneAgent Metric API](https://www.dynatrace.com/support/help/shortlink/local-api) also have in mind that you have a DDU credit for every HU buyed.

---

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [March 14, 2023, 5:20pm UTC](https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822/3 "2023-03-14T17:20:53Z")

</div>

Hi [@DanielS](https://community.dynatrace.com/user/35788)&nbsp;thank you for ur answer, they use the same&nbsp;ingestion protocol&nbsp;:grin:

Let me clarify what I’m trying to do. So, I will be using the Metric API and i want to change the metric unit to State.

For extension 1.0 I can see that I need to give the different states:  
[statemetrics-active-extension](https://www.dynatrace.com/support/help/shortlink/statemetrics-active-extension#define-states)

```markup
"states": ["OK", "Troubles", "Bad"],

```

I would like to know if its possible to create a custom metric with a state similar to this example.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 14, 2023, 5:44pm UTC](https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822/4 "2023-03-14T17:44:26Z")

</div>

In the [Metric API](https://www.dynatrace.com/support/help/shortlink/api-metrics-v2-get-descriptor#response-body-objects) it looks like the unit is a string not an array, i have done something for VPN states but (personally) i prefer to use numbers because i can apply more aggregations later. But if your metric Unit is States, then Ok, Trouble and Bad" will be values.

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [March 14, 2023, 8:28pm UTC](https://community.dynatrace.com/t/metrics-api-v2-unit-state/38822/5 "2023-03-14T20:28:14Z")

</div>

Hi&nbsp;[@rdinis](https://community.dynatrace.com/user/58355)

The unit only will change axis label but the metric still will hold a number

 ![Yosi_Neuman_3-1678825485961.png](https://global.discourse-cdn.com/dynatrace/original/3X/1/7/17c239a99f3aaa9b51a335af5f6799b69c690159.png)

Don’t think there is a way to send string to a metric

Yos
