# How to convert time typestring into date type

**URL:** https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714
**Category:** Logstash
**Created:** [November 21, 2018, 1:31pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714 "2018-11-21T13:31:49Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 21, 2018, 1:31pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/1 "2018-11-21T13:31:49Z")

</div>

HI,  
I want to convert on string time field into date type. My log is json format and its getting index into this field,

`bridgeNemoJenkinsData.time taken.keyword string`

I have implemented date filter to convert this as shown below,

```
date{
                        match => ["bridgeNemoJenkinsData.time taken","HH:mm:SSS"]
                        target => ["bridgeNemoJenkinsData.time taken"]
                 }

```

and get index like this ,

`bridgeNemoJenkinsData.time taken 00:08:027`

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 21, 2018, 1:54pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/2 "2018-11-21T13:54:10Z")

</div>

Can you please post your full config and example input lines and any errors you have? You should also not have a space in the field name, change it to bridgeNemoJenkinsData.time\_taken or similar.

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 21, 2018, 2:12pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/3 "2018-11-21T14:12:58Z")

</div>

> [@Eniqmatic](#):
>
> Can you please post your full config and example input lines and any errors you have

This is my filter section

```
 mutate{
                                add_field => {
                        "ci_cd" => "bridgeNemoDataType"
                        }
                        gsub => [
                               "message", "time taken", "time_taken"
                        ]
                 }
                 date{
                        match => ["bridgeNemoJenkinsData.time_taken","HH:mm:SSS"]
                        target => ["bridgeNemoJenkinsData.time_taken"]
                 }
                ruby {
                        init => "require 'socket'"
                        code => "event.set('logstash-hostname',Socket.gethostname)"
                }
                json{
                        source => "message"
                }

```

I dont have any error

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 21, 2018, 2:49pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/4 "2018-11-21T14:49:23Z")

</div>

Can you show some input lines and also what ends up being in the field?

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 21, 2018, 2:51pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/5 "2018-11-21T14:51:48Z")

</div>

> [@Eniqmatic](#):
>
> Can you show some input lines and also what ends up being in the field?

```
  kafka {
                type => "doc"
                bootstrap_servers => "xxx:443"
                topics => ["PaymentNet_500000846_xx"]
                security_protocol => "SSL"
                ssl_key_password => "kafkae1"
                ssl_keystore_location => "/tls/kafkae1-signed.keystore"
                ssl_keystore_password => "kafkae1"
                ssl_truststore_location => "/tls/kafka01-client-truststore.jks"
                ssl_truststore_password => "kafka123"
                key_deserializer_class => "org.apache.kafka.common.serialization.StringDeserializer"
                value_deserializer_class => "org.apache.kafka.common.serialization.StringDeserializer"
                group_id => "PaymentNet_group-id_500000846"
                auto_offset_reset => "earliest"
        }

```

this is my message

`{"bridgeNemoDataType":"nemo-jenkins-data","AIM_ID":"AIM","build_url":"https://cxx","stash_Url":"https://xx/tikr.git","bridgeNemoJenkinsData":{"build_Id":"22","current_branch":"develop","user":"Rohit Mohta","node_name":"jenkins-slave-8ncrq","stage_name":"DockerPublish","stage_result":"SUCCESS","pipeline_function":"Docker_Publish","time_taken":"00:21:448"}}`

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 26, 2018, 11:23am UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/6 "2018-11-26T11:23:16Z")

</div>

any update on my below input

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 26, 2018, 11:45am UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/7 "2018-11-26T11:45:18Z")

</div>

What does the end result look like?

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 26, 2018, 11:51am UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/8 "2018-11-26T11:51:29Z")

</div>

end result is look like that still in string type instead of data

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 26, 2018, 11:53am UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/9 "2018-11-26T11:53:07Z")

</div>

in Kibana? Did you change the mapping to date instead of string?

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 26, 2018, 12:02pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/10 "2018-11-26T12:02:45Z")

</div>

How can i change the mapping in kibana

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 26, 2018, 12:03pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/11 "2018-11-26T12:03:45Z")

</div>

Delete your indexes if you don't care about the data and it should be automatically picked up, otherwise you will have to put a template:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html)

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 26, 2018, 12:06pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/12 "2018-11-26T12:06:43Z")

</div>

> [@Eniqmatic](#):
>
> Delete your indexes if you don't care about the data and it should be automatically picked up, otherwise you will have to put a template:

Actually i tried to parsed that value into new index but even though it shows as string type

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 26, 2018, 12:10pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/13 "2018-11-26T12:10:23Z")

</div>

What is the index name? Can you go to the developer console in Kibana and do

GET index-name

And post the results?

---

<div class="post-metadata">

### Author: ![Ganesh2303](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Ganesh2303](https://discuss.elastic.co/u/Ganesh2303)
#### Post date: [November 26, 2018, 12:59pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/14 "2018-11-26T12:59:58Z")

</div>

> [@Eniqmatic](#):
>
> What is the index name? Can you go to the developer console in Kibana and do
> 
> GET index-name
> 
> And post the results?

please find my result

```
{
  "test-000001": {
    "aliases": {},
    "mappings": {
      "doc": {
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "ci_cd": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "logstash-hostname": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "message": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "tags": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "type": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1542959163031",
        "number_of_shards": "3",
        "number_of_replicas": "1",
        "uuid": "K7fNcr1eQaaFPDyHbg_wKg",
        "version": {
          "created": "6020499"
        },
        "provided_name": "test-000001"
      }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 26, 2018, 1:01pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/15 "2018-11-26T13:01:26Z")

</div>

There is no field in there called "bridgeNemoJenkinsData.time\_taken"

---

<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: [December 24, 2018, 1:01pm UTC](https://discuss.elastic.co/t/how-to-convert-time-typestring-into-date-type/157714/16 "2018-12-24T13:01:31Z")

</div>

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