# Is it possible to interpolate a field's value in a string?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-interpolate-a-fields-value-in-a-string/267027>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [March 12, 2021, 3:58am UTC](https://discuss.elastic.co/t/is-it-possible-to-interpolate-a-fields-value-in-a-string/267027 "2021-03-12T03:58:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![merricat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/merricat/32/85428_2.png) [@merricat](https://discuss.elastic.co/u/merricat)\
**Post date:** [March 12, 2021, 3:58am UTC](https://discuss.elastic.co/t/is-it-possible-to-interpolate-a-fields-value-in-a-string/267027/1 "2021-03-12T03:58:21Z")

</div>

Hi there, I've been messing with Filebeat for about 2 days now..  
I can't find a way to interpolate a field in another field. Here's what I have:

```auto
    processors:
      - add_fields:
          target: ""
          fields.mysubtype: "ABC"
      - add_fields:
          target: ""
          fields.type: "abc-%{mysubtype}"

```

Expecting my output to be:

```auto
    {
      "type": "abc-ABC"
    }

```

but the output is not interpolated, so the result remains:

```auto
    {
      "type": "abc-%{mysubtype}"
    }

```

I even tried with square brackets, i.e. "%{[mysubtype]}". This is on Filebeats v 7.11.2  
Any suggestions, ideas, pointers? 🙂 Thank you!

---

<div class="post-metadata">

**Author:** ![merricat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/merricat/32/85428_2.png) [@merricat](https://discuss.elastic.co/u/merricat)\
**Post date:** [March 12, 2021, 6:52pm UTC](https://discuss.elastic.co/t/is-it-possible-to-interpolate-a-fields-value-in-a-string/267027/2 "2021-03-12T18:52:08Z")

</div>

Ok, I found a solution. By using the `script` processor, I quickly achieved what I wanted. Seems weird that fields are not reference-able from any processor (i.e. in Logstash the format above works). Anyway, here's what I did:

```auto
- script:
    lang: javascript
    source: >
      function process(event) {
          event.Put("type", "abc-" + event.Get("mysubtype"));
      }

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 9, 2021, 8:52pm UTC](https://discuss.elastic.co/t/is-it-possible-to-interpolate-a-fields-value-in-a-string/267027/3 "2021-04-09T20:52:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
