# Elasticsearch-Logstash Mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-logstash-mapping/165217>\
**Category:** Elasticsearch\
**Created:** [January 22, 2019, 10:41am UTC](https://discuss.elastic.co/t/elasticsearch-logstash-mapping/165217 "2019-01-22T10:41:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gevorg](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@Gevorg](https://discuss.elastic.co/u/Gevorg)\
**Post date:** [January 22, 2019, 10:41am UTC](https://discuss.elastic.co/t/elasticsearch-logstash-mapping/165217/1 "2019-01-22T10:41:27Z")

</div>

Hello.  
I have ELK stack on the single server.  
Logstash have a two config files, first listen nginx logs over udp,  
Second config read logs from files.  
Nginx input:

> input {  
> syslog {  
> host =\> "0.0.0.0"  
> port =\> 5150  
> timezone =\> "UTC"  
> tags =\> "aws-nginx"  
> type =\> "log"  
> }  
> }
> 
> filter {...}
> 
> output {  
> elasticsearch {  
> hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
> index =\> "nginx-%{+YYYY.MM.dd}"  
> }  
> }

Logstash second config is:

> input {  
> file {  
> path =\> "/path/to/logs/\*"  
> start\_position =\> "beginning"  
> mode =\> "read"  
> }  
> }
> 
> filter {  
> grok {  
> patterns\_dir =\> "/etc/logstash/patterns"  
> match =\> { "message" =\> "%{POSTGRESQL}" }  
> }  
> }  
> output {  
> elasticsearch {  
> hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
> index =\> "rds-%{+YYYY.MM.dd}"  
> }  
> }

And from kibana dev tools, i create two templates for each index.  
PUT \_template/nginx1  
{  
"index\_patterns": "nginx\*",  
"settings": {  
"refresh\_interval": "5s",  
"number\_of\_replicas": 1,  
"number\_of\_shards": 2  
},  
"mappings": {  
"doc": {  
"dynamic\_templates": [  
{  
"message\_field": {  
"path\_match": "message",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "text",  
"norms": false  
}  
}  
},  
{  
"string\_fields": {  
"match": "\*",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
],  
"properties" : {  
"@timestamp" : {  
"type" : "date"  
},  
"remote\_addr" : {  
"type" : "ip"  
},  
"method" : {  
"type" : "text"  
},  
"refferer" : {  
"type" : "keyword"  
},  
"request\_time" : {  
"type" : "float"  
},  
"response\_bytes" : {  
"type" : "integer"  
},  
"user\_agent" : {  
"type" : "text"  
},  
"args\_body" : {  
"type" : "text"  
},  
"forwarded\_for" : {  
"type" : "text"  
},  
"@version" : {  
"type" : "keyword"  
},  
"geoip" : {  
"dynamic" : true,  
"properties" : {  
"ip" : {  
"type" : "ip"  
},  
"location" : {  
"type" : "geo\_point"  
},  
"latitude" : {  
"type" : "half\_float"  
},  
"longitude" : {  
"type" : "half\_float"  
}  
}  
}  
}  
}  
}  
}

Second:  
PUT \_template/rds  
{  
"index\_patterns": "rds\*",  
"settings": {  
"refresh\_interval": "5s",  
"number\_of\_replicas": 1,  
"number\_of\_shards": 2  
},  
"mappings": {  
"doc": {  
"dynamic\_templates": [  
{  
"message\_field": {  
"path\_match": "message",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "text",  
"norms": false  
}  
}  
},  
{  
"string\_fields": {  
"match": "\*",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
],  
"properties" : {  
"@timestamp" : {  
"type" : "date"  
},  
"private\_ip" : {  
"type" : "ip"  
},  
"request\_size" : {  
"type" : "integer"  
},  
"username" : {  
"type" : "text"  
},  
"database" : {  
"type" : "text"  
},  
"connection" : {  
"type" : "integer"  
},  
"duration" : {  
"type" : "float"  
},  
"query" : {  
"type" : "text"  
}  
}  
}  
}  
}

The problem appears, when elasticsearch create indexes. In the first(nginx) index i see mapping fields, which created for the second(rds) index.

 ![1](https://us1.discourse-cdn.com/elastic/original/3X/e/c/ec8dd1e9a13d43705c72092dff79ecedfed85424.png)  
 ![2](https://us1.discourse-cdn.com/elastic/original/3X/a/1/a1438550d186cce2c986ae3013a18a499cf54bba.png)  
rds-\*\*\* index starts receiving messages from nginx(over UDP), whilst I've configured elasticsearch and logstash to read messages from static files for RDS index.

If it's needed I can provide additional information.  
What im doing wrong ?

---

<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 19, 2019, 10:41am UTC](https://discuss.elastic.co/t/elasticsearch-logstash-mapping/165217/2 "2019-02-19T10:41:37Z")

</div>

Closed on February 19, 2019, 10:41am UTC

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