# Logstash Http Configuration

**URL:** <https://discuss.elastic.co/t/logstash-http-configuration/183868>\
**Category:** Logstash\
**Created:** [June 2, 2019, 6:32pm UTC](https://discuss.elastic.co/t/logstash-http-configuration/183868 "2019-06-02T18:32:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vigneshwar](https://avatars.discourse-cdn.com/v4/letter/v/9dc877/32.png) [@Vigneshwar](https://discuss.elastic.co/u/Vigneshwar)\
**Post date:** [June 2, 2019, 6:32pm UTC](https://discuss.elastic.co/t/logstash-http-configuration/183868/1 "2019-06-02T18:32:45Z")

</div>

Hi All,

I am trying to create multiple indices based on the input received to logstash via http. Here is my logstash configuration,

input {  
http {  
host =\> "0.0.0.0"  
port =\> "2020"  
type =\> ""  
}  
}

output{  
elasticsearch{  
hosts =\> "localhost:9200"  
index =\> "%{type}-%{+MM.dd.YYYY}"  
document\_type =\> "data"  
}  
}

In this, "type" field under input tag needs to be populated based on the input request. For example, Say i am sending http request like this "[http://0.0.0.0:2020/cpu](http://0.0.0.0:2020/cpu)" , then that cpu should get replaced in type field.

Similarly, for http request "[http://0.0.0.0:2020/memory](http://0.0.0.0:2020/memory)", memory should be replaced in type field.. Kindly help

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [June 3, 2019, 6:24am UTC](https://discuss.elastic.co/t/logstash-http-configuration/183868/2 "2019-06-03T06:24:27Z")

</div>

First of all, this option is deprecated in a newer logstash version and I would suggest you to not use it and just make this indices routing per tag/custom field name, not per deprecated field.

[https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-document\_type](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-document_type)

You can do that by:

- in a filter section catch that request, parse it with grok, and assign the /memory , /cpu etc. to the field you want it to be stored.
- in the output section you can do the following data allocation as you are attempting to do.

Example:

```
input {
	http {
		host => "0.0.0.0"
		port => "2020"
		type => ""
	}
}

filter {
	grok {
		match => {
			"message" => "^http://%{DATA}/%{DATA:request}$"
		}
	}
}
output{
	elasticsearch{
		hosts => "localhost:9200"
		index => "%{request}-%{+MM.dd.YYYY}"
	}
}
```

---

<div class="post-metadata">

**Author:** ![Vigneshwar](https://avatars.discourse-cdn.com/v4/letter/v/9dc877/32.png) [@Vigneshwar](https://discuss.elastic.co/u/Vigneshwar)\
**Post date:** [June 3, 2019, 8:26am UTC](https://discuss.elastic.co/t/logstash-http-configuration/183868/3 "2019-06-03T08:26:18Z")

</div>

@pastechecker : Thanks a lot Charlie. That's works perfectly fine for me 🙂

---

<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 1, 2019, 8:26am UTC](https://discuss.elastic.co/t/logstash-http-configuration/183868/4 "2019-07-01T08:26:23Z")

</div>

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