# How to use fields in http output plugin?

**URL:** <https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379>\
**Category:** Logstash\
**Created:** [July 31, 2020, 5:44pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379 "2020-07-31T17:44:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![srbhklkrn](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@srbhklkrn](https://discuss.elastic.co/u/srbhklkrn)\
**Post date:** [July 31, 2020, 5:44pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/1 "2020-07-31T17:44:00Z")

</div>

I want to attach syslog5424\_msg in message field in HTTP output plugin here is my current implementation, but it's erroring

> Failed to execute action

I'm not sure if we can interpolate fields in this plugin, any inputs?

```
http {
              http_method => "post"
              url => "https://hooks.slack.com/services/XXXX/XXX/XXXXX"
              format => "message"
              message => '{"channel": "alerts","text":' + %{syslog5424_msg} + '}'
    }

```

p.s it works when given simple string

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 31, 2020, 5:48pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/2 "2020-07-31T17:48:32Z")

</div>

> [@srbhklkrn](#):
>
> `message => '{"channel": "alerts","text":' + %{syslog5424_msg} + '}'`

Try

```
message => '{"channel": "alerts","text": %{syslog5424_msg} }'

```

---

<div class="post-metadata">

**Author:** ![srbhklkrn](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@srbhklkrn](https://discuss.elastic.co/u/srbhklkrn)\
**Post date:** [July 31, 2020, 5:53pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/3 "2020-07-31T17:53:59Z")

</div>

its erroring out, I think %{syslog5424\_msg} is not interpolating its value and slack rejecting this for invalid characters

> logstash\_1 | [2020-07-31T17:52:22,149][ERROR][logstash.outputs.http] [HTTP Output Failure] Encountered non-2xx HTTP code 400 {:response\_code=\>400, :url=\>"[https://hooks.slack.com/services/xxxx/xxx/xxxx](https://hooks.slack.com/services/xxxx/xxx/xxxx)", :event=\>#LogStash::Event:0x2ed9b640}

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 31, 2020, 5:59pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/4 "2020-07-31T17:59:48Z")

</div>

The http output definitely [sprintf's](https://github.com/logstash-plugins/logstash-output-http/blob/2cca9dc4acea7dadd203a6b0645bac0d825888d1/lib/logstash/outputs/http.rb#L305) the message field, so if the syslog5424\_msg field exists it should get interpolated.

---

<div class="post-metadata">

**Author:** ![srbhklkrn](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@srbhklkrn](https://discuss.elastic.co/u/srbhklkrn)\
**Post date:** [July 31, 2020, 6:06pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/5 "2020-07-31T18:06:11Z")

</div>

I can see the syslog5424\_msg field in the stdout, so we can rule that possibility out.

---

<div class="post-metadata">

**Author:** ![srbhklkrn](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@srbhklkrn](https://discuss.elastic.co/u/srbhklkrn)\
**Post date:** [July 31, 2020, 6:10pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/6 "2020-07-31T18:10:36Z")

</div>

This worked:

> `message => '{"channel": "alerts","text": "%{syslog5424_msg}" }'`

Thanks for the quick response 🙂

---

<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 28, 2020, 6:10pm UTC](https://discuss.elastic.co/t/how-to-use-fields-in-http-output-plugin/243379/7 "2020-08-28T18:10:39Z")

</div>

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