# Mappings, timestamps and templates

**URL:** <https://discuss.elastic.co/t/mappings-timestamps-and-templates/94141>\
**Category:** Elasticsearch\
**Created:** [July 21, 2017, 5:43pm UTC](https://discuss.elastic.co/t/mappings-timestamps-and-templates/94141 "2017-07-21T17:43:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elaair](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@elaair](https://discuss.elastic.co/u/elaair)\
**Post date:** [July 21, 2017, 5:43pm UTC](https://discuss.elastic.co/t/mappings-timestamps-and-templates/94141/1 "2017-07-21T17:43:12Z")

</div>

I have imported data into Elastic using the CSV plugin. The first two fields are a timestamp which I would like to perform analysis on in Elastic and Kibana. The issue I have is the the two time stamp fields are being imported as strings ( this was expected from available documentation). I have tried to use the date function in Logstash as well as trying a mapping template in order to obtain a date field and not a string. I am OK with the @timestamp reflecting the import time as I just want to use the createdTimeStamp and detectedTimeStamp for searching and analysis.  
Here are my relevant files.

The createTimeStamp and detectTimeStamp data from the file:  
6/1/17 05:31|5/31/17 08:38|

Logstash.conf  
input {

```
    file {
            path => ["/Users/schroew/Documents/ELK/resJune.psv"]
            type => "ResilientExport"
            tags => "ResilientTickets"
        }

```

} #close input

filter {  
if [path] == "/Users/schroew/Documents/ELK/resJune.psv" {  
csv {  
autodetect\_column\_names =\> "true"  
separator =\> "|"  
}  
date {  
match =\> ["createTimeStamp", "m/d/y H:M"]  
target =\> "createTimeStamp"  
}  
date {  
match =\> ["detectTimeStamp", "m/d/y H:M"]  
target =\> "detectTimeStamp"  
}  
mutate { convert =\> {"totalUsersImpacted" =\> "integer"} }  
mutate { remove\_field =\> ["message"] }

```
    } #close if

```

} # close filter

output {

elasticsearch {  
hosts =\> ["127.0.0.1:9200"]  
index =\> "resilient"  
}  
} #close output

My attempt at mapping-  
PUT \_template/resilienttemplate\_1  
{  
"template": "res\*",  
"settings": {  
"number\_of\_shards": 1  
},  
"mappings": {  
"type1": {  
"\_source": {  
"enabled": false  
},  
"properties": {  
"createTimeStamp": {  
"type": "date",  
"format": "mm/dd/yy HH:MM"  
},  
"detectTimeStamp": {  
"type": "date",  
"format": "mm/dd/yy HH:MM"  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![elaair](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@elaair](https://discuss.elastic.co/u/elaair)\
**Post date:** [July 25, 2017, 10:51pm UTC](https://discuss.elastic.co/t/mappings-timestamps-and-templates/94141/2 "2017-07-25T22:51:47Z")

</div>

I do have a better understanding of the date plugin now in log stash and was able to create a config that re-mappped the createTimeStamp to @timestamp. Still confused on how to create and use timestamps with Elastic and Logstash in general.  
New config  
input {

```
    file {
            path => ["/Users/Users/Documents/ELK/resJune.psv"]
            type => "ResilientExport"
            tags => "ResilientTickets"
        }

```

} #close input

filter {  
if [path] == "/Users/users/Documents/ELK/resJune.psv" {  
csv {  
autodetect\_column\_names =\> "true"  
separator =\> "|"  
}  
date {  
match =\> ["createTimeStamp", "M/d/yy H:mm", "M/dd/yy H:mm"]  
}  
mutate { convert =\> {"totalUsersImpacted" =\> "integer"} }  
mutate { remove\_field =\> ["message"] }

```
    } #close if

```

} # close filter

output {

elasticsearch {  
hosts =\> ["127.0.0.1:9200"]  
index =\> "resilient"  
}  
} #close output

---

<div class="post-metadata">

**Author:** ![elaair](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@elaair](https://discuss.elastic.co/u/elaair)\
**Post date:** [July 26, 2017, 2:14pm UTC](https://discuss.elastic.co/t/mappings-timestamps-and-templates/94141/3 "2017-07-26T14:14:21Z")

</div>

I got the two fields createTimeStamp and detectTimeStamp mappped to a date type using the following mapping:  
PUT \_template/resilienttemplate\_1  
{  
"template": "resilient-\*",  
"mappings": {  
"ticketDates": {  
"properties": {  
"createTimeStamp": {  
"type": "date",  
"format": "M/d/yy H:mm"  
},  
"detectTimeStamp": {  
"type": "date",  
"format": "M/d/yy H:mm"  
}  
}  
}  
}  
}

---

<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 23, 2017, 2:14pm UTC](https://discuss.elastic.co/t/mappings-timestamps-and-templates/94141/4 "2017-08-23T14:14:25Z")

</div>

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