# How to variables in log stash http output

**URL:** https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706
**Category:** Logstash
**Created:** [January 16, 2017, 9:50am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706 "2017-01-16T09:50:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![dineshangari](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@dineshangari](https://discuss.elastic.co/u/dineshangari)
#### Post date: [January 16, 2017, 9:50am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/1 "2017-01-16T09:50:36Z")

</div>

I have configuration file where input as csv and output as http.

I want to pass this csv columns as variable to http output.

Please suggest me way how to do that.

Thanks in Advance....

---

<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: [January 16, 2017, 9:58am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/2 "2017-01-16T09:58:11Z")

</div>

You should be able to use standard field references like `%{name of field}` in the options of the http output. If that doesn't work please show us what you've tried.

[https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references)

---

<div class="post-metadata">

### Author: ![rkhapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rkhapre/32/48333_2.png) [@rkhapre](https://discuss.elastic.co/u/rkhapre)
#### Post date: [January 16, 2017, 10:14am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/3 "2017-01-16T10:14:50Z")

</div>

I Also have similar issue with Logstash http output 5.x

where my message is like this

```
headers => {

         }
         format => "message"
	
   message => '{"ID":"%{ID}","requestNumber":"%{requestNumber}","requestTimestamp":"%{requestTimestamp}"}'

```

with this format, i am not able to get the http output  
However if i try using the hardcode value in message, its working perfectly for me

---

<div class="post-metadata">

### Author: ![dineshangari](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@dineshangari](https://discuss.elastic.co/u/dineshangari)
#### Post date: [January 16, 2017, 11:40am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/4 "2017-01-16T11:40:35Z")

</div>

I am also facing same as rkhapre mentioned

---

<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: [January 16, 2017, 12:02pm UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/5 "2017-01-16T12:02:20Z")

</div>

AFAICT from reading the code this should work. How do you know that the fields you're trying to insert exist in the event? Wouldn't it be easier and safer to use `format => "json"` instead and let Logstash take care of the JSON serialization?

---

<div class="post-metadata">

### Author: ![rkhapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rkhapre/32/48333_2.png) [@rkhapre](https://discuss.elastic.co/u/rkhapre)
#### Post date: [January 16, 2017, 1:26pm UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/6 "2017-01-16T13:26:06Z")

</div>

> [@rkhapre](#):
>
> message =\> '{"ID":"%{ID}","requestNumber":"%{requestNumber}","requestTimestamp":"%{requestTimestamp}"}'

This message is Raw payload, i cannot change it to format =\> "json"  
if i am making it json then also its not working

You have any working example with http output. Please suggest that

---

<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: [January 16, 2017, 1:51pm UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/7 "2017-01-16T13:51:45Z")

</div>

> This message is Raw payload, i cannot change it to format =\> "json"

So the payload you want to post isn't application/json but text/plain?

> if i am making it json then also its not working

Please show what you've tried and what results you get.

---

<div class="post-metadata">

### Author: ![rkhapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rkhapre/32/48333_2.png) [@rkhapre](https://discuss.elastic.co/u/rkhapre)
#### Post date: [January 17, 2017, 3:57am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/8 "2017-01-17T03:57:55Z")

</div>

Thanks magnusbaeck

I have resolved it, since i was using some mutate filter and generating new fields, it was not coming perfectly, as the filter it self was wrong. I discovered this in log files

Overall `%{name of field}` is working for me.

Thanks!

---

<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: [February 14, 2017, 3:58am UTC](https://discuss.elastic.co/t/how-to-variables-in-log-stash-http-output/71706/9 "2017-02-14T03:58:50Z")

</div>

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