# Use Stream Name and remove\_from\_default in route\_to\_stream()

**URL:** <https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295>\
**Category:** Graylog Central (peer support)\
**Tags:** pipeline-rules, route-to-streampl\
**Created:** [October 17, 2018, 11:45pm UTC](https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295 "2018-10-17T23:45:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![calebh](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@calebh](https://community.graylog.org/u/calebh)\
**Post date:** [October 17, 2018, 11:45pm UTC](https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295/1 "2018-10-17T23:45:31Z")

</div>

The documentation for the `route_to_stream()` Pipeline function isn’t clear on how to use **only** the stream name and set the `remove_from_default` parameter. Here’s a few calls I’ve tried, but the editor gives me various issues for each:

- `route_to_stream("Stream Name", true);`
- `route_to_stream("Stream Name", "", $message, true);`
- `route_to_stream("Stream Name", , , true);`
- `route_to_stream("Stream Name", $message, true);`

Any ideas how I’m supposed to use this function? Unfortunately I’m needing to move all of our stream routing into Pipeline rules because we need some processing before stream routing, and some after the routing.

---

<div class="post-metadata">

**Author:** ![calebh](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@calebh](https://community.graylog.org/u/calebh)\
**Post date:** [October 18, 2018, 5:08pm UTC](https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295/2 "2018-10-18T17:08:42Z")

</div>

I found that half my problem was in the API (see issue #5223: [https://github.com/Graylog2/graylog2-server/issues/5223](https://github.com/Graylog2/graylog2-server/issues/5223)). However, this still doesn’t change that this function is fairly undocumented, especially when referencing a stream by the name, and removing the message from the default stream.

This is an alternative I’ve come up with in the mean time:

```auto
route_to_stream("Stream Name", "", clone_message());
drop_message();

```

I feel like it adds unnecessary overhead for message processing, but it gets the job done for now.

Edit: don’t set `remove_from_default` to `true` with this method, because the message is never in the default stream to start with, and you’ll get warnings in the Graylog log file on the filesystem.

---

<div class="post-metadata">

**Author:** ![jan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jan/32/11_2.png) [@jan](https://community.graylog.org/u/jan)\
**Post date:** [October 19, 2018, 7:25am UTC](https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295/3 "2018-10-19T07:25:32Z")

</div>

You did not include what Graylog Version you are using … but for 2.4.6 I would look at the tests how they used this function:

> **[Graylog2/graylog-plugin-pipeline-processor](https://github.com/Graylog2/graylog-plugin-pipeline-processor/tree/master/plugin/src/test/resources/org/graylog/plugins/pipelineprocessor/functions)**
>
> \[DEPRECATED\] Graylog Pipeline Message Processor Plugins - Graylog2/graylog-plugin-pipeline-processor

In your case the following would be the way to go:

> <https://github.com/Graylog2/graylog-plugin-pipeline-processor/blob/master/plugin/src/test/resources/org/graylog/plugins/pipelineprocessor/functions/routeToStreamRemoveDefault.txt#L4>

---

<div class="post-metadata">

**Author:** ![calebh](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@calebh](https://community.graylog.org/u/calebh)\
**Post date:** [October 19, 2018, 4:44pm UTC](https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295/4 "2018-10-19T16:44:35Z")

</div>

That’ll do it! Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [November 2, 2018, 4:44pm UTC](https://community.graylog.org/t/use-stream-name-and-remove-from-default-in-route-to-stream/7295/5 "2018-11-02T16:44:44Z")

</div>

Closed on November 2, 2018, 4:44pm UTC

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