# Use field as value, remove field, then merge

**URL:** <https://community.grafana.com/t/use-field-as-value-remove-field-then-merge/61294>\
**Category:** Prometheus\
**Created:** [February 23, 2022, 3:32pm UTC](https://community.grafana.com/t/use-field-as-value-remove-field-then-merge/61294 "2022-02-23T15:32:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![txfz](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@txfz](https://community.grafana.com/u/txfz)\
**Post date:** [February 23, 2022, 3:32pm UTC](https://community.grafana.com/t/use-field-as-value-remove-field-then-merge/61294/1 "2022-02-23T15:32:48Z")

</div>

Hi,

I’m looking to merge some SNMP interface metrics. Most metrics use the same fields, but not all. For example, the interface type metric returns its value in a field.

```auto
ifHCInOctets{ifAlias="",ifDescr="bridge",ifIndex="26",ifName="bridge"} 4.02571046513016e+14
ifAdminStatus{ifAlias="",ifDescr="bridge",ifIndex="26",ifName="bridge"} 1
ifType_info{ifAlias="",ifDescr="bridge",ifIndex="26",ifName="bridge",ifType="bridge"} 1

```

The first two metrics may be merged, but the third one may not, due to the added `ifType` field.

Would it be possible to somehow use the `ifType` field as the value for that metric, and then remove the field, that it may be merged with the others?

I would like to avoid the join transformation if at all possible.

---

<div class="post-metadata">

**Author:** ![anon70503803](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@anon70503803](https://community.grafana.com/u/anon70503803)\
**Post date:** [April 14, 2022, 10:43pm UTC](https://community.grafana.com/t/use-field-as-value-remove-field-then-merge/61294/2 "2022-04-14T22:43:12Z")

</div>

you can accomplish a lot with Grafana’s transformations, even without using the join. If you’re still blocked on this the community might want to know what your data looks like now and how you want it to look like transformed:

> **[Reference: Transformation functions](https://grafana.com/docs/grafana/next/panels/reference-transformation-functions/)**
>
> Reference: Transformation functions You can perform the following transformations on your data.
> Add field from calculation Use this transformation to add a …

---

<div class="post-metadata">

**Author:** ![txfz](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@txfz](https://community.grafana.com/u/txfz)\
**Post date:** [April 19, 2022, 7:12am UTC](https://community.grafana.com/t/use-field-as-value-remove-field-then-merge/61294/3 "2022-04-19T07:12:13Z")

</div>

Hi,

Indeed, I have yet to solve this. So, the data looks as in my first post. Theoretically I would like it to look like so:

```auto
ifHCInOctets{ifAlias="",ifDescr="bridge",ifIndex="26",ifName="bridge"} 4.02571046513016e+14
ifAdminStatus{ifAlias="",ifDescr="bridge",ifIndex="26",ifName="bridge"} 1
ifType_info{ifAlias="",ifDescr="bridge",ifIndex="26",ifName="bridge"} "bridge"

```

That way I can merge all metrics.

My ultimate goal is to display for all interfaces their metrics in a table. Using the merge transformation gets me most of the way, with the notable exception of `ifType` with its additional label.

---

<div class="post-metadata">

**Author:** ![txfz](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@txfz](https://community.grafana.com/u/txfz)\
**Post date:** [April 19, 2022, 8:46am UTC](https://community.grafana.com/t/use-field-as-value-remove-field-then-merge/61294/4 "2022-04-19T08:46:56Z")

</div>

A different interface is a more clear example due to the interface type not matching the interface name.

```auto
ifHCInOctets{ifAlias="",ifDescr="ether1",ifIndex="3",ifName="ether1"} 4.02571046513016e+14
ifAdminStatus{ifAlias="",ifDescr="ether1",ifIndex="3",ifName="ether1"} 1
ifType_info{ifAlias="",ifDescr="ether1",ifIndex="3",ifName="ether1",ifType="ethernetCsmacd"} 1

```

To be transformed into:

```auto
ifHCInOctets{ifAlias="",ifDescr="ether1",ifIndex="3",ifName="ether1"} 4.02571046513016e+14
ifAdminStatus{ifAlias="",ifDescr="ether1",ifIndex="3",ifName="ether1"} 1
ifType_info{ifAlias="",ifDescr="ether1",ifIndex="3",ifName="ether1"} "ethernetCsmacd"

```
