# Message format in logstash output plugin

**URL:** <https://discuss.elastic.co/t/message-format-in-logstash-output-plugin/40614>\
**Category:** Logstash\
**Created:** [February 1, 2016, 8:01am UTC](https://discuss.elastic.co/t/message-format-in-logstash-output-plugin/40614 "2016-02-01T08:01:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bharath\_meka](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bharath\_meka](https://discuss.elastic.co/u/bharath_meka)\
**Post date:** [February 1, 2016, 8:01am UTC](https://discuss.elastic.co/t/message-format-in-logstash-output-plugin/40614/1 "2016-02-01T08:01:47Z")

</div>

Hi,

We have a custom logstash output plugin to post some messages to Slack. If I use a static message like "Testing from logstash", we are able to post it. But if I use logstash variables like %{message} or any other custom fields we defined, it is unable to resolve that field and is being as "%{message}". So for example, if I use the following output code, it is posted as "Trying from plugin: %{message}" . But I would need the actual log message to be posted to slack channel. Am I missing something here?

> output {  
> if "alert" in [tags] {  
> if [alert\_to] == "slack" {  
> slack {  
> channel =\> "#test-logstash-plugin"  
> description =\> "Trying from plugin: %{message}"  
> }  
> }   
> }  
> stdout { codec =\> rubydebug }  
> }

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 1, 2016, 8:19am UTC](https://discuss.elastic.co/t/message-format-in-logstash-output-plugin/40614/2 "2016-02-01T08:19:32Z")

</div>

To get `%{varname}` interpolation of strings, use e.g. `event.sprintf(@desecription)` instead of just `@description`.

(A public slack output plugin has been made available: [https://github.com/cyli/logstash-output-slack.)](https://github.com/cyli/logstash-output-slack.))

---

<div class="post-metadata">

**Author:** ![bharath\_meka](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bharath\_meka](https://discuss.elastic.co/u/bharath_meka)\
**Post date:** [February 2, 2016, 11:13am UTC](https://discuss.elastic.co/t/message-format-in-logstash-output-plugin/40614/3 "2016-02-02T11:13:28Z")

</div>

Thanks Magnus. It worked.

Regards,  
Bharath

---

<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:** [July 6, 2017, 5:13am UTC](https://discuss.elastic.co/t/message-format-in-logstash-output-plugin/40614/4 "2017-07-06T05:13:25Z")

</div>


