# Watcher: Multiple transforms

**URL:** <https://discuss.elastic.co/t/watcher-multiple-transforms/193476>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [August 2, 2019, 8:19am UTC](https://discuss.elastic.co/t/watcher-multiple-transforms/193476 "2019-08-02T08:19:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor.nilsson](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@victor.nilsson](https://discuss.elastic.co/u/victor.nilsson)\
**Post date:** [August 2, 2019, 8:19am UTC](https://discuss.elastic.co/t/watcher-multiple-transforms/193476/1 "2019-08-02T08:19:25Z")

</div>

Hi,

I was wondering if it is possible to use multiple transforms in a watch?

For example, i want to convert two values to GB from Bytes.

```
"transform" : {
    "script" : "return ['max_queue_size' : (ctx.payload.pipelines.main.queue.capacity.max_queue_size_in_bytes / 1024 / 1024 / 1024)]"
  },

```

That works but the in the same watch i want to do the same conversion for `'ctx.payload.pipelines.main.queue.capacity.queue_size_in_bytes'`.

In my mind i would then have to do something like this:

```
"transform" : {
    "script" : "return ['max_queue_size' : (ctx.payload.pipelines.main.queue.capacity.max_queue_size_in_bytes / 1024 / 1024 / 1024)]",
               "return ['current_queue_size' : (ctx.payload.pipelines.main.queue.capacity.queue_size_in_bytes / 1024 / 1024 / 1024)]
  },

```

However, that wont save the file and when i try to simulate the file i get the following error:

`[parse_exception] could not parse watch [_inlined_]. unexpected field [0]`

How can i achieve this?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 2, 2019, 8:43am UTC](https://discuss.elastic.co/t/watcher-multiple-transforms/193476/2 "2019-08-02T08:43:39Z")

</div>

you can do multiple transforms by returning a data structure that can contain multiple values, i.e. a map in your transform

```auto
def map = [:]
map.max_queue_size = ...;
map.current_queue_size = ...;
return map

```

hope this helps

---

<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:** [August 30, 2019, 8:43am UTC](https://discuss.elastic.co/t/watcher-multiple-transforms/193476/3 "2019-08-30T08:43:41Z")

</div>

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