# Urgent - Problem when parsing date

**URL:** https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464
**Category:** Elasticsearch
**Created:** [July 2, 2019, 9:28am UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464 "2019-07-02T09:28:10Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![soufiane1](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@soufiane1](https://discuss.elastic.co/u/soufiane1)
#### Post date: [July 2, 2019, 9:28am UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/1 "2019-07-02T09:28:10Z")

</div>

Hello everyone,

I am trying to load a csv file which contains a date field where data is sorted like the following example (01/07/2019 14:11), but receiving this elasticsearch error,

`"error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [Date et heure] of type [date] in document with id 'NmPZsWsBNbHi5-N-Z-Sm'", "caused_by"=>{"type"=>"date_time_exception", "reason"=>"Invalid value for MonthOfYear (valid values 1 - 12): 30"}}}}}`

Here is my config :

```
filter
{
	csv
	{
		separator => ","
		
		columns => ["Date et heure","Utilisateur","Code","Libelle evenement","Code retour","Application","Code site","Type de table","Objet Start","Usage cache","Valeur avant modif","Valeur apres modif","SDT"]
	}

		
	mutate{
	
	
		convert => { 
			
			"Utilisateur" => "string" 
			"Code" => "integer" 
			"Libellé évènement" => "string" 
			"Code retour" => "string" 
			"Application" => "string" 
			"Code site" => "string" 
			"Type de table" => "string"
			"Objet Start" => "string" 
			"Usage cache" => "string" 						
			"Valeur avant modif" => "string" 
			"Valeur après modif" => "string"
			"SDT" => "string"
		
		}
		
		
		#Gestion des accents
		rename => { "Libelle evenement" => "Libellé évènement"  
					"Valeur apres modif" => "Valeur après modif" }
}

```

I have defined the same date format in the mapping ( dd/MM/YYYY HH:mm)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 2, 2019, 10:58am UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/2 "2019-07-02T10:58:31Z")

</div>

What is the exact mapping of the index? Not the one you defined but the one you can get with:

```auto
GET indexname/_mapping

```

In the `output` part can you add a `stdout` output plugin so we can read what exactly is sent to elasticsearch?

---

<div class="post-metadata">

### Author: ![soufiane1](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@soufiane1](https://discuss.elastic.co/u/soufiane1)
#### Post date: [July 2, 2019, 11:04am UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/3 "2019-07-02T11:04:57Z")

</div>

this is what I get :

```
{
  "monbeaunode_1" : {
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "Application" : {
          "type" : "keyword"
        },
        "Code" : {
          "type" : "keyword"
        },
        "Code retour" : {
          "type" : "keyword"
        },
        "Code site" : {
          "type" : "keyword"
        },
        "Date et heure" : {
          "type" : "date",
          "format" : "DD/MM/YYYY HH:mm"
        },
        "Libellé évènement" : {
          "type" : "keyword"
        },
        "Objet Start" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "Objet start" : {
          "type" : "keyword"
        },
        "SDT" : {
          "type" : "keyword",
          "null_value" : "-"
        },
        "Type de table" : {
          "type" : "keyword"
        },
        "Usage cache" : {
          "type" : "keyword"
        },
        "Utilisateur" : {
          "type" : "keyword"
        },
        "Valeur après modif" : {
          "type" : "keyword"
        },
        "Valeur avant modif" : {
          "type" : "keyword",
          "null_value" : "NULL"
        }
      }
    }
  }
}

```

And here is my entire config :

```
###############################################################################################################

input
{
	file
	{
		path => "C:/Users/BEKRISO/KIBANA7.0.1/INPUT/9r_piste_audit.csv"
		start_position => "beginning"
		sincedb_path => "C:/Users/BEKRISO/KIBANA7.0.1/sincedb"
		codec => plain{charset =>"UTF-8"}
	}
}

############################################################################################################################

filter
{
	csv
	{
		separator => ","
		
		columns => ["Date et heure","Utilisateur","Code","Libelle evenement","Code retour","Application","Code site","Type de table","Objet Start","Usage cache","Valeur avant modif","Valeur apres modif","SDT"]
	}

		
	mutate{
	
	
		convert => { 
			
			"Utilisateur" => "string" 
			"Code" => "integer" 
			"Libellé évènement" => "string" 
			"Code retour" => "string" 
			"Application" => "string" 
			"Code site" => "string" 
			"Type de table" => "string"
			"Objet Start" => "string" 
			"Usage cache" => "string" 						
			"Valeur avant modif" => "string" 
			"Valeur après modif" => "string"
			"SDT" => "string"
		
		}
		
		
		#Gestion des accents
		rename => { "Libelle evenement" => "Libellé évènement"  
					"Valeur apres modif" => "Valeur après modif" }
					
		#suppression des champs inutiles  
		remove_field => ["message", "host", "path","@version", "@timestamp"]
		
		#Suppression des carriage returns(\r) du dernier champs
		gsub => ["message", "[\r]", "" ]	
			
	
	}
	
	date { match => ["Date et heure", "DD/MM/YYYY HH:mm"] }
	 
		#Remplacement des champs vide("NULL") par V1 car dans ESHMA V1 la version n'etait pas precisée
		#gsub => ["Valeur avant modif", "NULL", "V1"]	
		
		#if [Valeur avant modif] == "NULL" {	mutate {	replace => ["[Valeur avant modif]" , "V1" ]	}	}	
				
}

##############################################################################################################################

output
{
	stdout { codec => rubydebug }
	
	elasticsearch
	{
		hosts => "cas0000658713:9200"
		index => "monbeaunode_1"
	}

}

```

Kibana display "19/07/1970 01:11" for "19/07/2019 01:11", so it seems like it doesn't receive the year value,

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 2, 2019, 11:38am UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/4 "2019-07-02T11:38:26Z")

</div>

What is the output that you are getting with the `stdout` plugin? Could you share it please?

Also, I did not notice first but adding `Urgent` in the title does not bring any value or specific attention to your thread. Please don't do this.  
Specifically I don't think that your problem is more urgent than an issue with a production cluster which is down for 2 days for example...

---

<div class="post-metadata">

### Author: ![soufiane1](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@soufiane1](https://discuss.elastic.co/u/soufiane1)
#### Post date: [July 2, 2019, 11:55am UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/5 "2019-07-02T11:55:36Z")

</div>

![cap](https://us1.discourse-cdn.com/elastic/original/3X/a/1/a1b33f0381d5343a8554d1bd737967d05d1616b7.png)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 2, 2019, 12:22pm UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/6 "2019-07-02T12:22:03Z")

</div>

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with `</>` icon. Check the preview window.

---

<div class="post-metadata">

### Author: ![soufiane1](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@soufiane1](https://discuss.elastic.co/u/soufiane1)
#### Post date: [July 2, 2019, 1:44pm UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/7 "2019-07-02T13:44:30Z")

</div>

```
{
           "Utilisateur" => nil,
         "Type de table" => nil,
           "Code retour" => "05",
         "Date et heure" => "04/09/2018 12:53",
           "Application" => "9R",
           "Objet Start" => "RB-ZZZZ-0",
           "Usage cache" => "NON",
    "Valeur avant modif" => "V1",
                   "SDT" => nil,
    "Valeur après modif" => nil,
                  "Code" => 1,
             "Code site" => "0990",
     "Libellé évènement" => "Appel à la passerelle par une application cliente",
            "@timestamp" => 2018-01-04T11:53:00.000Z
}
{
           "Utilisateur" => nil,
         "Type de table" => nil,
           "Code retour" => "00",
         "Date et heure" => "04/09/2018 12:53",
           "Application" => "9R",
           "Objet Start" => "RB-FI05-0",
           "Usage cache" => "NON",
    "Valeur avant modif" => "V1",
                   "SDT" => nil,
    "Valeur après modif" => nil,
                  "Code" => 1,
             "Code site" => "0990",
     "Libellé évènement" => "Appel à la passerelle par une application cliente",
            "@timestamp" => 2018-01-04T11:53:00.000Z
}
{
           "Utilisateur" => nil,
         "Type de table" => "AS",
           "Code retour" => "00",
         "Date et heure" => "04/09/2018 12:52",
           "Application" => "9R",
           "Objet Start" => "TA-FI59-0",
           "Usage cache" => "NON",
    "Valeur avant modif" => "V1",
                   "SDT" => nil,
    "Valeur après modif" => nil,
                  "Code" => 1,
             "Code site" => "0990",
     "Libellé évènement" => "Appel à la passerelle par une application cliente",
            "@timestamp" => 2018-01-04T11:52:00.000Z
}
{
           "Utilisateur" => nil,
         "Type de table" => nil,
           "Code retour" => "02",
         "Date et heure" => "04/09/2018 08:04",
           "Application" => "TEST_ESHMA",
           "Objet Start" => "RB-NM252-0",
           "Usage cache" => "NON",
    "Valeur avant modif" => "V1",
                   "SDT" => nil,
    "Valeur après modif" => nil,
                  "Code" => 1,
             "Code site" => "0990",
     "Libellé évènement" => "Appel à la passerelle par une application cliente",
            "@timestamp" => 2018-01-04T07:04:00.000Z
}
```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 2, 2019, 3:41pm UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/8 "2019-07-02T15:41:45Z")

</div>

But one of the documents is generating a value `30` for the month. Could you share the document which is related to that? I can't reproduce any problem without the document which is having problems...

I guess you are using Elasticsearch 7.x, right?

---

<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 30, 2019, 3:41pm UTC](https://discuss.elastic.co/t/urgent-problem-when-parsing-date/188464/9 "2019-07-30T15:41:51Z")

</div>

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